Spaces:
Sleeping
Sleeping
Update auth.py
Browse files
auth.py
CHANGED
|
@@ -2,7 +2,7 @@ import jwt
|
|
| 2 |
import datetime
|
| 3 |
from passlib.hash import bcrypt
|
| 4 |
from storage import get_user, add_user
|
| 5 |
-
|
| 6 |
|
| 7 |
SECRET_KEY = "your-secret-key-keep-it-safe" # Change this in production!
|
| 8 |
ALGORITHM = "HS256"
|
|
@@ -34,7 +34,7 @@ def authenticate_user(username: str, password: str):
|
|
| 34 |
|
| 35 |
def register_user(username: str, password: str):
|
| 36 |
if get_user(username):
|
| 37 |
-
raise
|
| 38 |
hashed_password = get_password_hash(password)
|
| 39 |
add_user(username, hashed_password)
|
| 40 |
-
return {"username": username, "message": "User created successfully"}
|
|
|
|
| 2 |
import datetime
|
| 3 |
from passlib.hash import bcrypt
|
| 4 |
from storage import get_user, add_user
|
| 5 |
+
|
| 6 |
|
| 7 |
SECRET_KEY = "your-secret-key-keep-it-safe" # Change this in production!
|
| 8 |
ALGORITHM = "HS256"
|
|
|
|
| 34 |
|
| 35 |
def register_user(username: str, password: str):
|
| 36 |
if get_user(username):
|
| 37 |
+
raise ValueError("Username already registered")
|
| 38 |
hashed_password = get_password_hash(password)
|
| 39 |
add_user(username, hashed_password)
|
| 40 |
+
return {"username": username, "message": "User created successfully"}
|