def post(self, request, *args, **kwargs): super().post(request, *args, **kwargs) return Response( serializers.UserMFAMethodSerializer( request.user.mfa_methods.filter(is_active=True), many=True, ).data, status=status.HTTP_200_OK, )
def handle_mfa_response(self, user, mfa_method, *args, **kwargs): data = { 'ephemeral_token': user_token_generator.make_token(user), 'method': mfa_method.name, 'other_methods': serializers.UserMFAMethodSerializer( user.mfa_methods.filter(is_active=True, is_primary=False), many=True, ).data, } return Response(data)
def get(self, request, *args, **kwargs): active_mfa_methods = MFAMethod.objects.filter(user=request.user, is_active=True) serializer = serializers.UserMFAMethodSerializer(active_mfa_methods, many=True) return Response(serializer.data)