Browse Source

Make it possible to disable registrations

Fix #41
fix-mobile-margin
Bat 3 years ago
parent
commit
ac631627ab
  1. 4
      po/de.po
  2. 4
      po/en.po
  3. 4
      po/fr.po
  4. 4
      po/gl.po
  5. 4
      po/nb.po
  6. 4
      po/pl.po
  7. 3
      po/plume.pot
  8. 5
      src/routes/user.rs
  9. 20
      templates/users/new.html.tera

4
po/de.po

@ -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
po/en.po

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

4
po/fr.po

@ -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
po/gl.po

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

4
po/nb.po

@ -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
po/pl.po

@ -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
po/plume.pot

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

5
src/routes/user.rs

@ -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(|_| {

20
templates/users/new.html.tera

@ -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 %}
Loading…
Cancel
Save