Skip to content

Commit

Permalink
 リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
furutahidehiko committed Mar 21, 2024
1 parent 9115af5 commit a3fa691
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion application/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class JWTSettings(BaseSettings):
JWT_ALGORITHM: str = "HS256"
"""JWTトークンの署名に使用するアルゴリズム"""

JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 9
"""アクセストークンの有効期限(分)"""

JWT_REFRESH_TOKEN_EXPIRE_MINUTES: int = 90
Expand Down
4 changes: 2 additions & 2 deletions application/domain/user/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ async def create_token(user_id: str) -> AuthUserResponse:
Returns:
- AuthUserResponse: アクセストークン及びリフレッシュトークン。
"""
min = timedelta(minutes=jwt_settings.JWT_ACCESS_TOKEN_EXPIRE_MINUTES)
hours = timedelta(hours=jwt_settings.JWT_ACCESS_TOKEN_EXPIRE_MINUTES)
month = timedelta(days=jwt_settings.JWT_REFRESH_TOKEN_EXPIRE_MINUTES)
expire = datetime.now(ZoneInfo("Asia/Tokyo")) + min
expire = datetime.now(ZoneInfo("Asia/Tokyo")) + hours
refresh_expire = datetime.now(ZoneInfo("Asia/Tokyo")) + month
access_token = jwt.encode(
{"sub": str(user_id), "exp": expire},
Expand Down
5 changes: 4 additions & 1 deletion application/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ async def auth_token_router(
case _:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
error_description="grant_typeが不明です.",
detail={
"error": "invalid_grant_type",
"error_description": "grant_typeが不明です",
},
)

0 comments on commit a3fa691

Please sign in to comment.