Skip to content

Commit 6a7e025

Browse files
Auth fix (#45)
1 parent 709504d commit 6a7e025

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

calendar_backend/methods/auth.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ class UserInDB(User):
1717
password: str
1818

1919

20-
def get_user(db, username: str):
21-
if username in db:
22-
password = db[username]
20+
def get_user(db, token: str):
21+
if token in db.values():
22+
password = token
23+
for k, v in db.items():
24+
if v == token:
25+
username = k
2326
return UserInDB(username=username, password=password)
2427

2528

calendar_backend/routes/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ async def login(form_data: OAuth2PasswordRequestForm = Depends()):
2020
hashed_password = form_data.password
2121
if not hashed_password == user.password:
2222
raise HTTPException(status_code=400, detail="Incorrect username or password")
23-
return {"access_token": user.username, "token_type": "bearer"}
23+
return {"access_token": user.password, "token_type": "bearer"}

0 commit comments

Comments
 (0)