Commit 3a11c463 authored by Floréal Cabanettes's avatar Floréal Cabanettes

Check user is active on connexion + add register link + update translation

parent 216ef2d4
......@@ -15,9 +15,10 @@ from mongoengine.errors import DoesNotExist
from view.register import page as register
from view.panel import page as panel
from settings import SECRET_KEY, PASSWORD_HASH_ROUNDS
from exceptions import InvalidPassword, NotActiveUser
from settings import SECRET_KEY
from mail import send_mail
from model.recipe import Recipe, Ingredient, Instruction, Category
from model.user import User
......@@ -79,13 +80,21 @@ def login():
try:
user = User.objects.get(email=email)
if not check_password_hash(user.password, password):
raise DoesNotExist()
except DoesNotExist:
raise InvalidPassword()
if not user.active:
raise NotActiveUser()
except (DoesNotExist, InvalidPassword):
flash("error|" + _("Bad mail or password"))
if after is not None:
return redirect(url_for("login", email=email, after=after))
else:
return redirect(url_for("login", email=email))
except NotActiveUser:
flash("error|" + _("Your account is not active. Please check your e-mails to confirm your account"))
if after is not None:
return redirect(url_for("login", email=email, after=after))
else:
return redirect(url_for("login", email=email))
else:
session["email"] = email
session["is_authenticated"] = True
......
class InvalidPassword(Exception):
pass
class NotActiveUser(Exception):
pass
......@@ -13,10 +13,12 @@ fr = {
"Min 12 characters": "Min 12 caractères",
"Name": "Nom",
"Name must be less than 50 characters": "Le nom doit faire moins de 50 caractères",
"No account? Please": "Pas encore de compte ? Veuillez",
"Password": "Mot de passe",
"Password (confirmation)": "Mot de passe (confirmation)",
"Passwords does not match": "Les mot de passe ne correspondent pas",
"Register": "Créer un compte",
"Request fails. Please contact the support.": "La requête a échouée. Veuillez contacter le support.",
"Send": "Envoyer"
"Send": "Envoyer",
"register|||action": "vous enregistrer"
};
\ No newline at end of file
......@@ -22,6 +22,7 @@ Vue.component("main-login", {
</v-card-actions>
</form>
</v-card>
<p style="text-align: center; margin-top: 10px;">{{ tr("No account? Please") }} <a href='/register'>{{ tr("register", "action") }}</a>.</p>
</v-flex>
</v-layout>
</v-container>
......
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-09-08 22:35+0200\n"
"PO-Revision-Date: 2019-09-08 22:36+0200\n"
"POT-Creation-Date: 2019-09-14 16:55+0200\n"
"PO-Revision-Date: 2019-09-14 16:56+0200\n"
"Last-Translator: \n"
"Language: fr\n"
"Language-Team: fr <LL@li.org>\n"
......@@ -19,18 +19,26 @@ msgstr ""
"Generated-By: Babel 2.7.0\n"
"X-Generator: Poedit 2.0.6\n"
#: app.py:57 view/panel.py:18
#: app.py:62 view/panel.py:21
msgid "Panel"
msgstr "Panel"
#: app.py:69
#: app.py:74
msgid "Login"
msgstr "Connexion"
#: app.py:80
#: app.py:87
msgid "Bad mail or password"
msgstr "Mauvais e-mail ou mauvais mot de passe"
#: app.py:93
msgid ""
"Your account is not active. Please check your e-mails to confirm your "
"account"
msgstr ""
"Votre compte n'est pas activé. Veuillez vérifier vos mails afin de "
"valider votre compte"
#: templates/404.html:321
msgid "GO BACK HOME"
msgstr "RETOURNER À LA MAISON"
......@@ -39,7 +47,11 @@ msgstr "RETOURNER À LA MAISON"
msgid "Close"
msgstr "Fermer"
#: view/panel.py:12
#: view/panel.py:13
msgid "Not authenticated"
msgstr "Non authentifié"
#: view/panel.py:15
msgid "Please login to continue"
msgstr "Veuillez vous connecter pour continuer"
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-09-08 22:35+0200\n"
"POT-Creation-Date: 2019-09-14 16:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,18 +17,24 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\n"
#: app.py:57 view/panel.py:18
#: app.py:62 view/panel.py:21
msgid "Panel"
msgstr ""
#: app.py:69
#: app.py:74
msgid "Login"
msgstr ""
#: app.py:80
#: app.py:87
msgid "Bad mail or password"
msgstr ""
#: app.py:93
msgid ""
"Your account is not active. Please check your e-mails to confirm your "
"account"
msgstr ""
#: templates/404.html:321
msgid "GO BACK HOME"
msgstr ""
......@@ -37,7 +43,11 @@ msgstr ""
msgid "Close"
msgstr ""
#: view/panel.py:12
#: view/panel.py:13
msgid "Not authenticated"
msgstr ""
#: view/panel.py:15
msgid "Please login to continue"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment