Skip to content

Commit

Permalink
feat: add an api for checking authentication (is user expired or not)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmooHashem committed Jan 6, 2025
1 parent 98b9bcb commit b8edb17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from apps.accounts.views.change_password import ChangePasswordView
from apps.accounts.views.change_phone_number import change_phone_number_view
from apps.accounts.views.check_auth import CheckAuthenticationView
from apps.accounts.views.google_login import GoogleLogin
from apps.accounts.views.otp_login import OTPLoginView
from apps.accounts.views.simple_login import SimpleLogin
Expand All @@ -23,14 +24,17 @@
router.register(r'studentship', StudentshipViewSet, basename='studentships')

urlpatterns = [
path('accounts/check-authentication/',
CheckAuthenticationView.as_view(), name='check-authentication'),
path('accounts/refresh/', TokenRefreshView.as_view(), name='refresh_token'),

path('accounts/simple-login/', SimpleLogin.as_view(), name='simple-login'),
path('accounts/otp-login/', OTPLoginView.as_view(), name='otp-login'),
path("accounts/google-login/", GoogleLogin.as_view(), name="google-login"),
path("accounts/uuid-login/", UserIDLoginView.as_view(), name="uuid-login"),

path('accounts/verification-code/', VerificationCodeView.as_view(),
name="send-verification-code"),
path('accounts/refresh/', TokenRefreshView.as_view(), name='refresh_token'),
path('accounts/change-password/',
ChangePasswordView.as_view(), name="change-password"),
path("accounts/change-phone-number/",
Expand Down
10 changes: 10 additions & 0 deletions apps/accounts/views/check_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated


class CheckAuthenticationView(APIView):
permission_classes = [IsAuthenticated]

def get(self, request):
return Response({'status': 'authenticated'})

0 comments on commit b8edb17

Please sign in to comment.