Flash localized messages from auth

This commit is contained in:
Kiril Kovachev 2024-10-14 12:52:07 +01:00
parent 934f7ae676
commit 21f1035b66
2 changed files with 16 additions and 6 deletions

View File

@ -14,9 +14,9 @@ def register():
error = None error = None
if not username: if not username:
error = "Username is required." error = "username_required"
elif not password: elif not password:
error = "Password is required." error = "password_required"
if error is None: if error is None:
try: try:
@ -46,9 +46,9 @@ def login():
).fetchone() ).fetchone()
if user is None: if user is None:
error = "Incorrect username." error = "incorrect_username"
elif not check_password_hash(user["password"], password): elif not check_password_hash(user["password"], password):
error = "Incorrect password." error = "incorrect_password"
if error is None: if error is None:
session.clear() session.clear()

View File

@ -12,7 +12,9 @@ EXISTING_STRINGS = {
"search", "search",
"search_placeholder", "search_placeholder",
"include_kanji", "include_kanji",
"include_kotoba" "include_kotoba",
"username_required",
"password_required"
} }
ENGLISH = { ENGLISH = {
@ -29,7 +31,11 @@ ENGLISH = {
"search": "Search", "search": "Search",
"search_placeholder": "Enter kanji or word", "search_placeholder": "Enter kanji or word",
"include_kanji": "Include kanji", "include_kanji": "Include kanji",
"include_kotoba": "Include kotoba" "include_kotoba": "Include kotoba",
"username_required": "Username required.",
"password_required": "Password required.",
"incorrect_username": "Incorrect username.",
"incorrect_password": "Incorrect password."
} }
JAPANESE = { JAPANESE = {
@ -47,6 +53,10 @@ JAPANESE = {
"search_placeholder": "漢字・言葉を入力", "search_placeholder": "漢字・言葉を入力",
"include_kanji": "漢字を含む", "include_kanji": "漢字を含む",
"include_kotoba": "言葉を含む", "include_kotoba": "言葉を含む",
"username_required": "ユーザー名が必要です",
"password_required": "パスワードが必要です",
"incorrect_username": "ユーザー名が違います",
"incorrect_password": "パスワードが違います"
} }
LANGUAGES = [ LANGUAGES = [