mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-25 21:11:01 +00:00
Fix #167
This commit is contained in:
parent
53a0ec08a2
commit
7fc5d7b5b0
9 changed files with 54 additions and 25 deletions
8
po/de.po
8
po/de.po
|
@ -310,8 +310,9 @@ msgid "We need an email or a username to identify you"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Wir brauchen eine E-Mail oder einen Nutzernamen um dich zu identifizieren"
|
"Wir brauchen eine E-Mail oder einen Nutzernamen um dich zu identifizieren"
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
#, fuzzy
|
||||||
msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"
|
msgid "Your password can't be empty"
|
||||||
|
msgstr "Dein Kommentar kann nicht leer sein"
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
msgstr "Passwörter stimmen nicht überein"
|
msgstr "Passwörter stimmen nicht überein"
|
||||||
|
@ -436,3 +437,6 @@ msgstr "Artikel geschrieben haben"
|
||||||
|
|
||||||
msgid "Read the detailed rules"
|
msgid "Read the detailed rules"
|
||||||
msgstr "Lies die detailierten Regeln"
|
msgstr "Lies die detailierten Regeln"
|
||||||
|
|
||||||
|
#~ msgid "Your password should be at least 8 characters long"
|
||||||
|
#~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"
|
||||||
|
|
2
po/en.po
2
po/en.po
|
@ -307,7 +307,7 @@ msgstr ""
|
||||||
msgid "We need an email or a username to identify you"
|
msgid "We need an email or a username to identify you"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
msgid "Your password can't be empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
|
|
15
po/fr.po
15
po/fr.po
|
@ -308,8 +308,9 @@ msgstr ""
|
||||||
"Nous avons besoin d'une adresse mail ou d'un nom d'utilisateur pour vous "
|
"Nous avons besoin d'une adresse mail ou d'un nom d'utilisateur pour vous "
|
||||||
"identifier."
|
"identifier."
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
#, fuzzy
|
||||||
msgstr "Votre mot de passe doit faire au moins 8 caractères."
|
msgid "Your password can't be empty"
|
||||||
|
msgstr "Votre commentaire ne peux pas être vide"
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
msgstr "Les mots de passe ne correspondent pas."
|
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 ""
|
msgid ""
|
||||||
"Articles are also visible on other Plume websites, and you can interact with "
|
"Articles are also visible on other Plume websites, and you can interact with "
|
||||||
"them directly from other platforms like Mastodon."
|
"them directly from other platforms like Mastodon."
|
||||||
msgstr "Les articles sont également visibles sur d'autres sites Plume et "
|
msgstr ""
|
||||||
"vous pouvez interagir avec eux directement depuis d'autres plateformes "
|
"Les articles sont également visibles sur d'autres sites Plume et vous pouvez "
|
||||||
"telles que Mastodon."
|
"interagir avec eux directement depuis d'autres plateformes telles que "
|
||||||
|
"Mastodon."
|
||||||
|
|
||||||
msgid "Create your account"
|
msgid "Create your account"
|
||||||
msgstr "Créer votre compte"
|
msgstr "Créer votre compte"
|
||||||
|
@ -435,3 +437,6 @@ msgstr "articles"
|
||||||
|
|
||||||
msgid "Read the detailed rules"
|
msgid "Read the detailed rules"
|
||||||
msgstr "Lisez le détail des règles"
|
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."
|
||||||
|
|
2
po/gl.po
2
po/gl.po
|
@ -301,7 +301,7 @@ msgstr ""
|
||||||
msgid "We need an email or a username to identify you"
|
msgid "We need an email or a username to identify you"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
msgid "Your password can't be empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
|
|
22
po/nb.po
22
po/nb.po
|
@ -46,7 +46,9 @@ msgid "Something broke on our side."
|
||||||
msgstr "Noe gikk feil i vår ende."
|
msgstr "Noe gikk feil i vår ende."
|
||||||
|
|
||||||
msgid "Sorry about that. If you think this is a bug, please report it."
|
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"
|
msgid "Configuration"
|
||||||
msgstr "Oppsett"
|
msgstr "Oppsett"
|
||||||
|
@ -68,7 +70,8 @@ msgstr "Meldinger"
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
|
"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."
|
msgid "This article is under the {{ license }} license."
|
||||||
msgstr "Denne artikkelen er publisert med lisensen {{ license }}"
|
msgstr "Denne artikkelen er publisert med lisensen {{ license }}"
|
||||||
|
@ -132,7 +135,9 @@ msgid "Your Blogs"
|
||||||
msgstr "Dine blogger"
|
msgstr "Dine blogger"
|
||||||
|
|
||||||
msgid "You don't have any blog yet. Create your own, or ask to join one."
|
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"
|
msgid "Start a new blog"
|
||||||
msgstr "Start en ny blogg"
|
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"
|
msgid "We need an email or a username to identify you"
|
||||||
msgstr "Vi trenger en epost eller et brukernavn for å identifisere deg"
|
msgstr "Vi trenger en epost eller et brukernavn for å identifisere deg"
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
#, fuzzy
|
||||||
msgstr "Passordet ditt må bestå av minst åtte tegn"
|
msgid "Your password can't be empty"
|
||||||
|
msgstr "Kommentaren din kan ikke være tom"
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
msgstr "Passordene stemmer ikke overens"
|
msgstr "Passordene stemmer ikke overens"
|
||||||
|
@ -322,7 +328,8 @@ msgstr[0] "Én forfatter av denne bloggen: "
|
||||||
msgstr[1] "{{ count }} forfattere av denne bloggen: "
|
msgstr[1] "{{ count }} forfattere av denne bloggen: "
|
||||||
|
|
||||||
msgid "Login or use your Fediverse account to interact with this article"
|
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"
|
msgid "Optional"
|
||||||
msgstr "Valgfritt"
|
msgstr "Valgfritt"
|
||||||
|
@ -425,3 +432,6 @@ msgstr "artikler"
|
||||||
|
|
||||||
msgid "Read the detailed rules"
|
msgid "Read the detailed rules"
|
||||||
msgstr "Les reglene"
|
msgstr "Les reglene"
|
||||||
|
|
||||||
|
#~ msgid "Your password should be at least 8 characters long"
|
||||||
|
#~ msgstr "Passordet ditt må bestå av minst åtte tegn"
|
||||||
|
|
8
po/pl.po
8
po/pl.po
|
@ -314,8 +314,9 @@ msgid "We need an email or a username to identify you"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Potrzebujemy nazwy użytkownika lub adresu e-mail, aby Cię zidentyfikować"
|
"Potrzebujemy nazwy użytkownika lub adresu e-mail, aby Cię zidentyfikować"
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
#, fuzzy
|
||||||
msgstr "Twoje hasło musi składać się przynajmniej z 8 znaków"
|
msgid "Your password can't be empty"
|
||||||
|
msgstr "Twój komentarz nie może być pusty"
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
msgstr "Hasła nie pasują do siebie"
|
msgstr "Hasła nie pasują do siebie"
|
||||||
|
@ -443,5 +444,8 @@ msgstr "artykuły"
|
||||||
msgid "Read the detailed rules"
|
msgid "Read the detailed rules"
|
||||||
msgstr "Przeczytaj szczegółowe zasady"
|
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"
|
#~ msgid "Logowanie"
|
||||||
#~ msgstr "Zaloguj się"
|
#~ msgstr "Zaloguj się"
|
||||||
|
|
|
@ -300,7 +300,7 @@ msgstr ""
|
||||||
msgid "We need an email or a username to identify you"
|
msgid "We need an email or a username to identify you"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Your password should be at least 8 characters long"
|
msgid "Your password can't be empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Passwords are not matching"
|
msgid "Passwords are not matching"
|
||||||
|
|
|
@ -4,6 +4,7 @@ use rocket::{
|
||||||
request::{LenientForm,FlashMessage}
|
request::{LenientForm,FlashMessage}
|
||||||
};
|
};
|
||||||
use rocket_contrib::Template;
|
use rocket_contrib::Template;
|
||||||
|
use std::borrow::Cow;
|
||||||
use validator::{Validate, ValidationError, ValidationErrors};
|
use validator::{Validate, ValidationError, ValidationErrors};
|
||||||
|
|
||||||
use plume_models::{
|
use plume_models::{
|
||||||
|
@ -40,7 +41,7 @@ fn new_message(user: Option<User>, message: Message) -> Template {
|
||||||
struct LoginForm {
|
struct LoginForm {
|
||||||
#[validate(length(min = "1", message = "We need an email or a username to identify you"))]
|
#[validate(length(min = "1", message = "We need an email or a username to identify you"))]
|
||||||
email_or_name: String,
|
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
|
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())
|
let user = User::find_by_email(&*conn, form.email_or_name.to_string())
|
||||||
.map(|u| Ok(u))
|
.map(|u| Ok(u))
|
||||||
.unwrap_or_else(|| User::find_local(&*conn, form.email_or_name.to_string()).map(|u| Ok(u)).unwrap_or(Err(())));
|
.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() {
|
let mut errors = match form.validate() {
|
||||||
Ok(_) => ValidationErrors::new(),
|
Ok(_) => ValidationErrors::new(),
|
||||||
Err(e) => e
|
Err(e) => e
|
||||||
};
|
};
|
||||||
if let Err(_) = user.clone() {
|
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()) {
|
} 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() {
|
if errors.is_empty() {
|
||||||
cookies.add_private(Cookie::new(AUTH_COOKIE, user.unwrap().id.to_string()));
|
cookies.add_private(Cookie::new(AUTH_COOKIE, user.unwrap().id.to_string()));
|
||||||
Ok(Redirect::to(Uri::new(flash
|
Ok(Redirect::to(Uri::new(flash
|
||||||
|
@ -68,8 +73,9 @@ fn create(conn: DbConn, data: LenientForm<LoginForm>, flash: Option<FlashMessage
|
||||||
.unwrap_or("/".to_owned()))
|
.unwrap_or("/".to_owned()))
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
println!("{:?}", errors);
|
||||||
Err(Template::render("session/login", json!({
|
Err(Template::render("session/login", json!({
|
||||||
"account": user,
|
"account": null,
|
||||||
"errors": errors.inner(),
|
"errors": errors.inner(),
|
||||||
"form": form
|
"form": form
|
||||||
})))
|
})))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{{ macros::input(name="email_or_name", label="Username or email", errors=errors, form=form, props='minlenght="1"') }}
|
{{ 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" | _ }}" />
|
<input type="submit" value="{{ "Login" | _ }}" />
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue