Make it possible to disable registrations

Fix #41
This commit is contained in:
Bat
2018-09-03 17:05:45 +01:00
parent 1d65582abe
commit ac631627ab
9 changed files with 44 additions and 8 deletions
+4
View File
@@ -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"
+4
View File
@@ -493,3 +493,7 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
+4
View File
@@ -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."
+4
View File
@@ -499,3 +499,7 @@ msgstr ""
msgid "Send"
msgstr ""
msgid ""
"Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
+4
View File
@@ -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"
+4
View File
@@ -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"
+3
View File
@@ -483,3 +483,6 @@ msgstr ""
msgid "Send"
msgstr ""
msgid "Sorry, but registrations are closed on this instance. Try to find another one"
msgstr ""
+5
View File
@@ -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(|_| {
+12 -8
View File
@@ -6,13 +6,17 @@
{% endblock title %}
{% block content %}
<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"') }}
{% 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>
<input type="submit" value="{{ "Create account" | _ }}" />
</form>
{% else %}
<p class="center">{{ "Sorry, but registrations are closed on this instance. Try to find another one" | _ }}</p>
{% endif %}
{% endblock content %}