Spaces:
Sleeping
Sleeping
Update auth_token.py
Browse files- auth_token.py +5 -4
auth_token.py
CHANGED
|
@@ -379,12 +379,13 @@ def complete_signup(username, email, password, otp_input):
|
|
| 379 |
def login(username_or_email, password):
|
| 380 |
user = _get_user(username_or_email)
|
| 381 |
if not user:
|
| 382 |
-
return False, None, "Account not found. Please sign up first."
|
| 383 |
if user["password"] != hash_password(password):
|
| 384 |
-
return False, None, "Incorrect password. Please try again."
|
| 385 |
token = generate_token()
|
| 386 |
-
|
| 387 |
-
|
|
|
|
| 388 |
|
| 389 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 390 |
# TOKEN / LOGOUT
|
|
|
|
| 379 |
def login(username_or_email, password):
|
| 380 |
user = _get_user(username_or_email)
|
| 381 |
if not user:
|
| 382 |
+
return False, None, None, "Account not found. Please sign up first."
|
| 383 |
if user["password"] != hash_password(password):
|
| 384 |
+
return False, None, None, "Incorrect password. Please try again."
|
| 385 |
token = generate_token()
|
| 386 |
+
real_username = user["username"] # always the stored username, never the email
|
| 387 |
+
_update_user(real_username, {"token": token, "last_login": time.time()})
|
| 388 |
+
return True, token, real_username, "Login successful!"
|
| 389 |
|
| 390 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 391 |
# TOKEN / LOGOUT
|