diff --git a/app.py b/app.py index 2ce171e..59e045b 100644 --- a/app.py +++ b/app.py @@ -99,7 +99,15 @@ def login_submit(request: Request, email: str = Form(...), password: str = Form( ) row = cur.fetchone() - if row is None or not bcrypt.checkpw(password.encode("utf-8"), row[2].encode("utf-8")): + if row is None: + return templates.TemplateResponse( + request, "login.html", {"error": "E-Mail oder Passwort ist falsch."}, status_code=401 + ) + + # psycopg liefert TEXT-Spalten hier als bytes zurück, nicht als str. + stored_hash = row[2] if isinstance(row[2], bytes) else row[2].encode("utf-8") + + if not bcrypt.checkpw(password.encode("utf-8"), stored_hash): return templates.TemplateResponse( request, "login.html", {"error": "E-Mail oder Passwort ist falsch."}, status_code=401 )