Skip to content

Commit

Permalink
Feat: 로그아웃 API 접근 권한 및 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
fnzksxl committed Sep 2, 2024
1 parent 37d3e63 commit 8f159b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 10 additions & 6 deletions wtnt/user/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ def process_response_data(self, response_data):
return response_data, access_token

def logout(self):
_, access_token = self.request.META.get("HTTP_AUTHORIZATION").split(" ")
try:
user_id = AccessToken(access_token, verify=False).payload.get("user_id")
except TokenError:
raise token_exception.InvalidTokenError()
RedisUtils.delete_refresh_token(user_id)
authorization = self.request.META.get("HTTP_AUTHORIZATION", None)
if authorization:
_, access_token = authorization.split(" ")
try:
user_id = AccessToken(access_token, verify=False).payload.get("user_id")
except TokenError:
raise token_exception.InvalidTokenError()
RedisUtils.delete_refresh_token(user_id)
else:
token_exception.NoTokenInAuthorizationHeaderError()


class RegisterService(BaseService):
Expand Down
4 changes: 1 addition & 3 deletions wtnt/user/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework.views import APIView
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.permissions import AllowAny
from rest_framework import status
from rest_framework_simplejwt.views import TokenRefreshView
from dj_rest_auth.registration.views import SocialLoginView
Expand Down Expand Up @@ -46,8 +46,6 @@ def post(self, request, *args, **kwargs):


class LogoutView(APIView):
permission_classes = [IsAuthenticated]

def post(self, request, *args, **kwargs):
auth_service = AuthService(request)
auth_service.logout()
Expand Down

0 comments on commit 8f159b3

Please sign in to comment.