Spaces:
Runtime error
Runtime error
Pushing solution to bug
Browse files- src/auth.py +2 -2
- src/routers/token.py +1 -3
src/auth.py
CHANGED
|
@@ -120,7 +120,7 @@ async def get_verified_device(
|
|
| 120 |
return device_orm
|
| 121 |
|
| 122 |
|
| 123 |
-
|
| 124 |
username: str,
|
| 125 |
password: str,
|
| 126 |
db: SQLAlchemySessionType = Depends(get_db)
|
|
@@ -129,7 +129,7 @@ async def authenticate_user(
|
|
| 129 |
Authenticates a user by username and password.
|
| 130 |
Returns the ORM User model if successful, raises HTTPException otherwise.
|
| 131 |
"""
|
| 132 |
-
user =
|
| 133 |
|
| 134 |
if not user:
|
| 135 |
return None # User not found, return None
|
|
|
|
| 120 |
return device_orm
|
| 121 |
|
| 122 |
|
| 123 |
+
def authenticate_user(
|
| 124 |
username: str,
|
| 125 |
password: str,
|
| 126 |
db: SQLAlchemySessionType = Depends(get_db)
|
|
|
|
| 129 |
Authenticates a user by username and password.
|
| 130 |
Returns the ORM User model if successful, raises HTTPException otherwise.
|
| 131 |
"""
|
| 132 |
+
user = crud.get_user_by_username(db, username)
|
| 133 |
|
| 134 |
if not user:
|
| 135 |
return None # User not found, return None
|
src/routers/token.py
CHANGED
|
@@ -28,9 +28,7 @@ async def login_for_access_token(
|
|
| 28 |
This is the primary login endpoint. It takes a username and password
|
| 29 |
and returns an access token if the credentials are valid.
|
| 30 |
"""
|
| 31 |
-
user =
|
| 32 |
-
authenticate_user, db, form_data.username, form_data.password
|
| 33 |
-
)
|
| 34 |
if not user:
|
| 35 |
raise HTTPException(
|
| 36 |
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
|
|
| 28 |
This is the primary login endpoint. It takes a username and password
|
| 29 |
and returns an access token if the credentials are valid.
|
| 30 |
"""
|
| 31 |
+
user = authenticate_user(db, form_data.username, form_data.password)
|
|
|
|
|
|
|
| 32 |
if not user:
|
| 33 |
raise HTTPException(
|
| 34 |
status_code=status.HTTP_401_UNAUTHORIZED,
|