Skip to content

Commit ceebff5

Browse files
committed
Adjusted logic in 'password' block of 'generate_token()' to avoid uninitialised local variable
1 parent fb19d6c commit ceebff5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/murfey/server/api/auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,15 @@ async def generate_token(
360360
access_token = token.get("access_token")
361361
else:
362362
validated = validate_user(form_data.username, form_data.password)
363+
access_token = create_access_token(
364+
data={"user": form_data.username},
365+
)
363366
if not validated:
364367
raise HTTPException(
365368
status_code=status.HTTP_401_UNAUTHORIZED,
366369
detail="Incorrect username or password",
367370
headers={"WWW-Authenticate": "Bearer"},
368371
)
369-
if not auth_url:
370-
access_token = create_access_token(
371-
data={"user": form_data.username},
372-
)
373372
return Token(access_token=access_token, token_type="bearer")
374373

375374
# Return empty token otherwise

0 commit comments

Comments
 (0)