Skip to content

Commit

Permalink
fix: access token 생성 위치 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkweon17 committed Feb 15, 2024
1 parent f842876 commit a182241
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
File renamed without changes.
9 changes: 6 additions & 3 deletions src/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ async def kakao_login(token_data: TokenData, db: Session = Depends(get_db)):

user = db.query(LUsers).filter(LUsers.kakao_id == user_info['id']).first()

access_token = jwt.encode({"sub": str(user.user_id), "exp": datetime.utcnow(
) + timedelta(weeks=4)}, SECRET_KEY, algorithm=ALGORITHM)

if user is None:
new_user = LUsers(
kakao_id=user_info['id'], name=user_info['properties']['nickname'])
db.add(new_user)
db.commit()
new_user.access_token = access_token

access_token = jwt.encode({"sub": str(new_user.user_id), "exp": datetime.utcnow() + timedelta(weeks=4)}, SECRET_KEY, algorithm=ALGORITHM)

return new_user

access_token = jwt.encode({"sub": str(user.user_id), "exp": datetime.utcnow(
) + timedelta(weeks=4)}, SECRET_KEY, algorithm=ALGORITHM)

user.access_token = access_token
return user
Expand Down

0 comments on commit a182241

Please sign in to comment.