From 7fc5d7b5b0f45617b6069e211fcd7ced3ac51980 Mon Sep 17 00:00:00 2001 From: Bat Date: Sat, 18 Aug 2018 12:37:40 +0200 Subject: [PATCH] Fix #167 --- po/de.po | 8 ++++++-- po/en.po | 2 +- po/fr.po | 15 ++++++++++----- po/gl.po | 2 +- po/nb.po | 22 ++++++++++++++++------ po/pl.po | 8 ++++++-- po/plume.pot | 2 +- src/routes/session.rs | 18 ++++++++++++------ templates/session/login.html.tera | 2 +- 9 files changed, 54 insertions(+), 25 deletions(-) diff --git a/po/de.po b/po/de.po index 60fae7ce..9b4b2ecf 100644 --- a/po/de.po +++ b/po/de.po @@ -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" diff --git a/po/en.po b/po/en.po index 65f3682f..d365eb0b 100644 --- a/po/en.po +++ b/po/en.po @@ -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" diff --git a/po/fr.po b/po/fr.po index cd78a35b..8ce372d1 100644 --- a/po/fr.po +++ b/po/fr.po @@ -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." diff --git a/po/gl.po b/po/gl.po index 8f4cb620..d5a558df 100644 --- a/po/gl.po +++ b/po/gl.po @@ -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" diff --git a/po/nb.po b/po/nb.po index 2588ad0a..c7d7b1c2 100644 --- a/po/nb.po +++ b/po/nb.po @@ -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" diff --git a/po/pl.po b/po/pl.po index 9619efc5..3d0367fd 100644 --- a/po/pl.po +++ b/po/pl.po @@ -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ę" diff --git a/po/plume.pot b/po/plume.pot index d2a32d84..51dc694a 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -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" diff --git a/src/routes/session.rs b/src/routes/session.rs index fd79f057..d6e73b32 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -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, 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, flash: Option 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, flash: Option {{ 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"') }}