From 7397ffd45011414448ba9f58146ed6863cac18e7 Mon Sep 17 00:00:00 2001 From: "Mahmoud.Adel" Date: Thu, 9 Jul 2020 10:53:41 +0200 Subject: [PATCH] do token generation only when allauth_settings.EMAIL_VERIFICATION is not set to 'MANDATORY' --- dj_rest_auth/registration/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dj_rest_auth/registration/views.py b/dj_rest_auth/registration/views.py index cdd5b94..5f338bd 100644 --- a/dj_rest_auth/registration/views.py +++ b/dj_rest_auth/registration/views.py @@ -69,10 +69,12 @@ class RegisterView(CreateAPIView): def perform_create(self, serializer): user = serializer.save(self.request) - if getattr(settings, 'REST_USE_JWT', False): - self.access_token, self.refresh_token = jwt_encode(user) - else: - create_token(self.token_model, user, serializer) + if allauth_settings.EMAIL_VERIFICATION != \ + allauth_settings.EmailVerificationMethod.MANDATORY: + if getattr(settings, 'REST_USE_JWT', False): + self.access_token, self.refresh_token = jwt_encode(user) + else: + create_token(self.token_model, user, serializer) complete_signup(self.request._request, user, allauth_settings.EMAIL_VERIFICATION,