Make it possible to disable registrations

Fix #41
fix-mobile-margin
Bat 6 years ago
parent 1d65582abe
commit ac631627ab

@ -504,5 +504,9 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
#~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"

@ -493,3 +493,7 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""

@ -500,3 +500,7 @@ msgstr "Fichier"
msgid "Send"
msgstr "Envoyer"
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr "Désolé, mais les inscriptions sont fermées sur cette instance. Essayez d'en trouver une autre."

@ -499,3 +499,7 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""

@ -508,6 +508,10 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
#~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Én deling"

@ -519,6 +519,10 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
#~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Jedno udostępnienie"

@ -483,3 +483,6 @@ msgstr ""
msgid "Send"
msgstr ""
msgid "Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""

@ -166,6 +166,7 @@ fn activity_details(name: String, conn: DbConn, _ap: ApRequest) -> ActivityStrea
#[get("/users/new")]
fn new(user: Option<User>, conn: DbConn) -> Template {
Template::render("users/new", json!({
"enabled": Instance::get_local(&*conn).map(|i| i.open_registrations).unwrap_or(true),
"account": user.map(|u| u.to_json(&*conn)),
"errors": null,
"form": null
@ -228,6 +229,10 @@ fn passwords_match(form: &NewUserForm) -> Result<(), ValidationError> {
#[post("/users/new", data = "<data>")]
fn create(conn: DbConn, data: LenientForm<NewUserForm>) -> Result<Redirect, Template> {
if !Instance::get_local(&*conn).map(|i| i.open_registrations).unwrap_or(true) {
return Ok(Redirect::to(uri!(new))); // Actually, it is an error
}
let form = data.get();
form.validate()
.map(|_| {

@ -6,13 +6,17 @@
{% endblock title %}
{% block content %}
<h1>{{ "Create an account" | _ }}</h1>
<form method="post">
{% if enabled %}
<h1>{{ "Create an account" | _ }}</h1>
<form method="post">
{{ macros::input(name="username", label="Username", errors=errors, form=form, props='minlenght="1"') }}
{{ macros::input(name="email", label="Email", errors=errors, form=form, type="email") }}
{{ macros::input(name="password", label="Password", errors=errors, form=form, type="password", props='minlenght="8"') }}
{{ macros::input(name="password_confirmation", label="Password confirmation", errors=errors, form=form, type="password", props='minlenght="8"') }}
<input type="submit" value="{{ "Create account" | _ }}" />
</form>
</form>
{% else %}
<p class="center">{{ "Sorry, but registrations are closed on this instance. Try to find another one" | _ }}</p>
{% endif %}
{% endblock content %}

Loading…
Cancel
Save