@@ -1,10 +1,7 @@ -from django.utils.translation import gettext as _ from ninja import Router from ninja.errors import HttpError -from rest_framework_simplejwt.exceptions import TokenError -from rest_framework_simplejwt.tokens import RefreshToken -from authentication.schemas import UserSchema, RefreshInSchema, AccessOutSchema +from authentication.schemas import UserSchema from authentication.security import SyncAuthBearer from authentication.selectors.user_selector import UserSelector @@ -18,12 +15,3 @@ def get_user_data(request): return UserSelector.detail(user=request.auth, provider=request.provider) except Exception as exc: raise HttpError(400, f'{exc}') - - -@router.post('refresh', auth=None, tags=['auth/refresh'], response=AccessOutSchema) -def refresh_token(request, payload: RefreshInSchema): - try: - refresh = RefreshToken(payload.refresh) - return AccessOutSchema(access=str(refresh.access_token)) - except TokenError: - raise HttpError(401, _('Invalid or expired refresh token')) @@ -43,11 +43,3 @@ class UserSchema(Schema): def resolve_account_type(obj: CustomUserModel): return obj.account_type - -class RefreshInSchema(Schema): - refresh: str - - -class AccessOutSchema(Schema): - access: str - @@ -67,6 +67,7 @@ urlpatterns = [ views.UpdateProfilePictureAPIView.as_view(), name='update-profile-pic', ), + path('token/refresh', TokenRefreshView.as_view(), name='refresh-jwt'), path( 'business-host', views.BusinessHostAPIView.as_view(), @@ -1369,10 +1369,6 @@ msgstr "Отсутствует обязательный параметр: 'messa msgid "Model not found" msgstr "Модель не найдена" -#: authentication/routes/v1.py:28 -msgid "Invalid or expired refresh token" -msgstr "Неверный или истёкший refresh токен" - #~ msgid "" #~ "Error occured when create generation. It may cause NSFW-content not " #~ "allowed, retry again"