2019-03-17 19:10:45 +00:00
|
|
|
@use std::borrow::Cow;
|
2020-01-21 06:02:03 +00:00
|
|
|
@use validator::{ValidationErrors, ValidationErrorsKind};
|
|
|
|
@use crate::templates::base;
|
|
|
|
@use crate::template_utils::*;
|
|
|
|
@use crate::routes::user::NewUserForm;
|
|
|
|
@use crate::routes::*;
|
2018-12-06 17:54:16 +00:00
|
|
|
|
|
|
|
@(ctx: BaseContext, enabled: bool, form: &NewUserForm, errors: ValidationErrors)
|
|
|
|
|
2019-02-02 14:23:50 +00:00
|
|
|
@:base(ctx, i18n!(ctx.1, "Create your account"), {}, {}, {
|
2018-12-06 17:54:16 +00:00
|
|
|
@if enabled {
|
|
|
|
<h1>@i18n!(ctx.1, "Create an account")</h1>
|
2018-12-07 11:05:01 +00:00
|
|
|
<form method="post" action="@uri!(user::create)">
|
2019-03-17 19:10:45 +00:00
|
|
|
@if let Some(ValidationErrorsKind::Field(errs)) = errors.clone().errors().get("__all__") {
|
2019-08-27 14:50:24 +00:00
|
|
|
<p class="error">@errs[0].message.as_ref().unwrap_or(&Cow::from("Unknown error"))</p>
|
2019-03-17 19:10:45 +00:00
|
|
|
}
|
2019-08-27 14:50:24 +00:00
|
|
|
|
2019-10-24 14:44:14 +00:00
|
|
|
@(Input::new("username", i18n!(ctx.1, "Username"))
|
2019-08-27 14:50:24 +00:00
|
|
|
.default(&form.username)
|
|
|
|
.error(&errors)
|
|
|
|
.set_prop("minlength", 1)
|
|
|
|
.html(ctx.1))
|
2019-10-24 14:44:14 +00:00
|
|
|
@(Input::new("email", i18n!(ctx.1, "Email"))
|
2019-08-27 14:50:24 +00:00
|
|
|
.default(&form.email)
|
|
|
|
.error(&errors)
|
|
|
|
.set_prop("minlength", 1)
|
|
|
|
.html(ctx.1))
|
2019-10-24 14:44:14 +00:00
|
|
|
@(Input::new("password", i18n!(ctx.1, "Password"))
|
2019-08-27 14:50:24 +00:00
|
|
|
.default(&form.password)
|
|
|
|
.error(&errors)
|
|
|
|
.set_prop("minlength", 8)
|
|
|
|
.input_type("password")
|
|
|
|
.html(ctx.1))
|
2019-10-24 14:44:14 +00:00
|
|
|
@(Input::new("password_confirmation", i18n!(ctx.1, "Password confirmation"))
|
2019-08-27 14:50:24 +00:00
|
|
|
.default(&form.password_confirmation)
|
|
|
|
.error(&errors)
|
|
|
|
.set_prop("minlength", 8)
|
|
|
|
.input_type("password")
|
|
|
|
.html(ctx.1))
|
2018-12-06 17:54:16 +00:00
|
|
|
|
2018-12-24 18:03:54 +00:00
|
|
|
<input type="submit" value="@i18n!(ctx.1, "Create your account")" />
|
2018-12-06 17:54:16 +00:00
|
|
|
</form>
|
|
|
|
} else {
|
2018-12-24 18:03:54 +00:00
|
|
|
<p class="center">@i18n!(ctx.1, "Apologies, but registrations are closed on this particular instance. You can, however, find a different one.")</p>
|
2018-12-06 17:54:16 +00:00
|
|
|
}
|
|
|
|
})
|