From df02b1987c00681fbac3a0628f8db3427c9e2b37 Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Mon, 12 Aug 2024 11:57:01 -0700 Subject: [PATCH] Actually add API key to email /login route --- store/app/routers/users.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/store/app/routers/users.py b/store/app/routers/users.py index b9ad1527..7624e696 100644 --- a/store/app/routers/users.py +++ b/store/app/routers/users.py @@ -18,7 +18,6 @@ from store.app.routers.auth.github import github_auth_router from store.app.utils.email import send_delete_email from store.app.utils.password import verify_password -from store.utils import new_uuid logger = logging.getLogger(__name__) @@ -232,9 +231,13 @@ async def login_user(data: LoginRequest, user_crud: UserCrud = Depends()) -> Log if user.hashed_password is None or not verify_password(data.password, user.hashed_password): raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid email or password") - token = new_uuid() + api_key = await user_crud.add_api_key( + user.id, + source="oauth", + permissions="full", + ) - return LoginResponse(user_id=user.id, token=token) + return LoginResponse(user_id=user.id, token=api_key.id) @users_router.get("/batch", response_model=PublicUserInfoResponse)