This commit is contained in:
Bat 2018-08-18 12:37:40 +02:00
parent 53a0ec08a2
commit 7fc5d7b5b0
9 changed files with 54 additions and 25 deletions

View File

@ -310,8 +310,9 @@ msgid "We need an email or a username to identify you"
msgstr ""
"Wir brauchen eine E-Mail oder einen Nutzernamen um dich zu identifizieren"
msgid "Your password should be at least 8 characters long"
msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"
#, fuzzy
msgid "Your password can't be empty"
msgstr "Dein Kommentar kann nicht leer sein"
msgid "Passwords are not matching"
msgstr "Passwörter stimmen nicht überein"
@ -436,3 +437,6 @@ msgstr "Artikel geschrieben haben"
msgid "Read the detailed rules"
msgstr "Lies die detailierten Regeln"
#~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"

View File

@ -307,7 +307,7 @@ msgstr ""
msgid "We need an email or a username to identify you"
msgstr ""
msgid "Your password should be at least 8 characters long"
msgid "Your password can't be empty"
msgstr ""
msgid "Passwords are not matching"

View File

@ -308,8 +308,9 @@ msgstr ""
"Nous avons besoin d'une adresse mail ou d'un nom d'utilisateur pour vous "
"identifier."
msgid "Your password should be at least 8 characters long"
msgstr "Votre mot de passe doit faire au moins 8 caractères."
#, fuzzy
msgid "Your password can't be empty"
msgstr "Votre commentaire ne peux pas être vide"
msgid "Passwords are not matching"
msgstr "Les mots de passe ne correspondent pas."
@ -411,9 +412,10 @@ msgstr "Les auteurs peuvent gérer différents blogs au sein d'un même site."
msgid ""
"Articles are also visible on other Plume websites, and you can interact with "
"them directly from other platforms like Mastodon."
msgstr "Les articles sont également visibles sur d'autres sites Plume et "
"vous pouvez interagir avec eux directement depuis d'autres plateformes "
"telles que Mastodon."
msgstr ""
"Les articles sont également visibles sur d'autres sites Plume et vous pouvez "
"interagir avec eux directement depuis d'autres plateformes telles que "
"Mastodon."
msgid "Create your account"
msgstr "Créer votre compte"
@ -435,3 +437,6 @@ msgstr "articles"
msgid "Read the detailed rules"
msgstr "Lisez le détail des règles"
#~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Votre mot de passe doit faire au moins 8 caractères."

View File

@ -301,7 +301,7 @@ msgstr ""
msgid "We need an email or a username to identify you"
msgstr ""
msgid "Your password should be at least 8 characters long"
msgid "Your password can't be empty"
msgstr ""
msgid "Passwords are not matching"

View File

@ -46,7 +46,9 @@ msgid "Something broke on our side."
msgstr "Noe gikk feil i vår ende."
msgid "Sorry about that. If you think this is a bug, please report it."
msgstr "Beklager så mye. Dersom du tror dette er en bug, vær grei å rapportér det til oss."
msgstr ""
"Beklager så mye. Dersom du tror dette er en bug, vær grei å rapportér det "
"til oss."
msgid "Configuration"
msgstr "Oppsett"
@ -68,7 +70,8 @@ msgstr "Meldinger"
msgid ""
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
msgstr "Skrevet av {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape}}{{ link_3 }}"
msgstr ""
"Skrevet av {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape}}{{ link_3 }}"
msgid "This article is under the {{ license }} license."
msgstr "Denne artikkelen er publisert med lisensen {{ license }}"
@ -132,7 +135,9 @@ msgid "Your Blogs"
msgstr "Dine blogger"
msgid "You don't have any blog yet. Create your own, or ask to join one."
msgstr "Du har ingen blogger enda. Lag din egen, eller be om å få bli med på en annen."
msgstr ""
"Du har ingen blogger enda. Lag din egen, eller be om å få bli med på en "
"annen."
msgid "Start a new blog"
msgstr "Start en ny blogg"
@ -301,8 +306,9 @@ msgstr "Et innlegg med samme navn finnes allerede."
msgid "We need an email or a username to identify you"
msgstr "Vi trenger en epost eller et brukernavn for å identifisere deg"
msgid "Your password should be at least 8 characters long"
msgstr "Passordet ditt må bestå av minst åtte tegn"
#, fuzzy
msgid "Your password can't be empty"
msgstr "Kommentaren din kan ikke være tom"
msgid "Passwords are not matching"
msgstr "Passordene stemmer ikke overens"
@ -322,7 +328,8 @@ msgstr[0] "Én forfatter av denne bloggen: "
msgstr[1] "{{ count }} forfattere av denne bloggen: "
msgid "Login or use your Fediverse account to interact with this article"
msgstr "Logg inn eller bruk din Fediverse-konto for å gjøre noe med denne artikkelen"
msgstr ""
"Logg inn eller bruk din Fediverse-konto for å gjøre noe med denne artikkelen"
msgid "Optional"
msgstr "Valgfritt"
@ -425,3 +432,6 @@ msgstr "artikler"
msgid "Read the detailed rules"
msgstr "Les reglene"
#~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Passordet ditt må bestå av minst åtte tegn"

View File

@ -314,8 +314,9 @@ msgid "We need an email or a username to identify you"
msgstr ""
"Potrzebujemy nazwy użytkownika lub adresu e-mail, aby Cię zidentyfikować"
msgid "Your password should be at least 8 characters long"
msgstr "Twoje hasło musi składać się przynajmniej z 8 znaków"
#, fuzzy
msgid "Your password can't be empty"
msgstr "Twój komentarz nie może być pusty"
msgid "Passwords are not matching"
msgstr "Hasła nie pasują do siebie"
@ -443,5 +444,8 @@ msgstr "artykuły"
msgid "Read the detailed rules"
msgstr "Przeczytaj szczegółowe zasady"
#~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Twoje hasło musi składać się przynajmniej z 8 znaków"
#~ msgid "Logowanie"
#~ msgstr "Zaloguj się"

View File

@ -300,7 +300,7 @@ msgstr ""
msgid "We need an email or a username to identify you"
msgstr ""
msgid "Your password should be at least 8 characters long"
msgid "Your password can't be empty"
msgstr ""
msgid "Passwords are not matching"

View File

@ -4,6 +4,7 @@ use rocket::{
request::{LenientForm,FlashMessage}
};
use rocket_contrib::Template;
use std::borrow::Cow;
use validator::{Validate, ValidationError, ValidationErrors};
use plume_models::{
@ -40,7 +41,7 @@ fn new_message(user: Option<User>, message: Message) -> Template {
struct LoginForm {
#[validate(length(min = "1", message = "We need an email or a username to identify you"))]
email_or_name: String,
#[validate(length(min = "8", message = "Your password should be at least 8 characters long"))]
#[validate(length(min = "1", message = "Your password can't be empty"))]
password: String
}
@ -50,17 +51,21 @@ fn create(conn: DbConn, data: LenientForm<LoginForm>, flash: Option<FlashMessage
let user = User::find_by_email(&*conn, form.email_or_name.to_string())
.map(|u| Ok(u))
.unwrap_or_else(|| User::find_local(&*conn, form.email_or_name.to_string()).map(|u| Ok(u)).unwrap_or(Err(())));
let mut errors = match form.validate() {
Ok(_) => ValidationErrors::new(),
Err(e) => e
};
if let Err(_) = user.clone() {
errors.add("email_or_name", ValidationError::new("invalid_login"))
let mut err = ValidationError::new("invalid_login");
err.message = Some(Cow::from("Invalid username or password"));
errors.add("email_or_name", err)
} else if !user.clone().expect("User not found").auth(form.password.clone()) {
errors.add("email_or_name", ValidationError::new("invalid_login"))
let mut err = ValidationError::new("invalid_login");
err.message = Some(Cow::from("Invalid username or password"));
errors.add("email_or_name", err)
}
if errors.is_empty() {
cookies.add_private(Cookie::new(AUTH_COOKIE, user.unwrap().id.to_string()));
Ok(Redirect::to(Uri::new(flash
@ -68,8 +73,9 @@ fn create(conn: DbConn, data: LenientForm<LoginForm>, flash: Option<FlashMessage
.unwrap_or("/".to_owned()))
))
} else {
println!("{:?}", errors);
Err(Template::render("session/login", json!({
"account": user,
"account": null,
"errors": errors.inner(),
"form": form
})))

View File

@ -12,7 +12,7 @@
{% endif %}
<form method="post">
{{ macros::input(name="email_or_name", label="Username or email", errors=errors, form=form, props='minlenght="1"') }}
{{ macros::input(name="password", label="Password", errors=errors, form=form, type="password", props='minlenght="8"') }}
{{ macros::input(name="password", label="Password", errors=errors, form=form, type="password", props='minlenght="1"') }}
<input type="submit" value="{{ "Login" | _ }}" />
</form>