mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Removed simplejwt related code
This commit is contained in:
@@ -6,7 +6,8 @@ from rest_framework import filters, permissions, response, viewsets
|
||||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
# from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
from modoboa.admin.api.v1 import serializers as admin_v1_serializers
|
||||
from modoboa.core.api.v1 import serializers as core_v1_serializers
|
||||
@@ -79,20 +80,20 @@ class AccountViewSet(core_v1_viewsets.AccountViewSet):
|
||||
serializer = serializers.UserAPITokenSerializer({"token": str(token)})
|
||||
return response.Response(serializer.data, status=status)
|
||||
|
||||
@action(methods=["post"], detail=False, url_path="tfa/verify")
|
||||
def tfa_verify_code(self, request):
|
||||
"""Verify given code validity."""
|
||||
serializer = serializers.VerifyTFACodeSerializer(
|
||||
data=request.data, context={"user": request.user}
|
||||
)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
refresh = RefreshToken.for_user(request.user)
|
||||
refresh[constants.TFA_DEVICE_TOKEN_KEY] = serializer.validated_data[
|
||||
"code"
|
||||
].persistent_id
|
||||
return response.Response(
|
||||
{"refresh": str(refresh), "access": str(refresh.access_token)}
|
||||
)
|
||||
# @action(methods=["post"], detail=False, url_path="tfa/verify")
|
||||
# def tfa_verify_code(self, request):
|
||||
# """Verify given code validity."""
|
||||
# serializer = serializers.VerifyTFACodeSerializer(
|
||||
# data=request.data, context={"user": request.user}
|
||||
# )
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
# refresh = RefreshToken.for_user(request.user)
|
||||
# refresh[constants.TFA_DEVICE_TOKEN_KEY] = serializer.validated_data[
|
||||
# "code"
|
||||
# ].persistent_id
|
||||
# return response.Response(
|
||||
# {"refresh": str(refresh), "access": str(refresh.access_token)}
|
||||
# )
|
||||
|
||||
@action(methods=["get"], detail=False, url_path="tfa/setup/key")
|
||||
def tfa_setup_get_key(self, request):
|
||||
@@ -129,13 +130,13 @@ class AccountViewSet(core_v1_viewsets.AccountViewSet):
|
||||
request.user.save()
|
||||
# Generate new tokens
|
||||
device = request.user.totpdevice_set.first()
|
||||
refresh = RefreshToken.for_user(request.user)
|
||||
refresh[constants.TFA_DEVICE_TOKEN_KEY] = device.persistent_id
|
||||
# refresh = RefreshToken.for_user(request.user)
|
||||
# refresh[constants.TFA_DEVICE_TOKEN_KEY] = device.persistent_id
|
||||
return response.Response(
|
||||
{
|
||||
"tokens": tokens,
|
||||
"refresh": str(refresh),
|
||||
"access": str(refresh.access_token),
|
||||
# "refresh": str(refresh),
|
||||
# "access": str(refresh.access_token),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user