Skip to content

Commit

Permalink
Add role field to JWTUser schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shem8 committed Oct 15, 2024
1 parent d2f1f59 commit 9149a2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/app/models/schemas/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class JWTMeta(BaseModel):

class JWTUser(BaseModel):
username: str
role: UserRole
2 changes: 1 addition & 1 deletion backend/app/services/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create_jwt_token(

def create_access_token_for_user(user: User, secret_key: str) -> str:
return create_jwt_token(
jwt_content=JWTUser(username=user.username).dict(),
jwt_content=JWTUser(username=user.username, role=user.role).dict(),
secret_key=secret_key,
expires_delta=timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES),
)
Expand Down

0 comments on commit 9149a2a

Please sign in to comment.