コード例 #1
0
ファイル: views.py プロジェクト: ITOO-UrFU/NOTV
    def get_response_data(self, user):

        if getattr(settings, 'REST_USE_JWT', False):
            data = {'user': user, 'token': self.token}
            return JWTSerializer(data).data
        else:
            return TokenSerializer(user.auth_token).data
コード例 #2
0
 def create(self, request, *args, **kwargs):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = self.perform_create(serializer)
     headers = self.get_success_headers(serializer.data)
     return Response(TokenSerializer(user.auth_token).data,
                     status=status.HTTP_201_CREATED,
                     headers=headers)
コード例 #3
0
 def get_response_data(self, user):
     if allauth_settings.EMAIL_VERIFICATION == \
             allauth_settings.EmailVerificationMethod.MANDATORY:
         return {"detail": _("Verification e-mail sent.")}
     if getattr(settings, 'REST_USE_JWT', False):
         data = {'user': user, 'token': self.token}
         return JWTSerializer(data).data
     else:
         return TokenSerializer(user.auth_token).data
コード例 #4
0
    def get_response_data(self, user):
        if allauth_settings.EMAIL_VERIFICATION == \
                allauth_settings.EmailVerificationMethod.MANDATORY:
            return {"detail": _("Verification e-mail sent.")}

        minimal_user_serializer = ProfileUserSerializer(user)

        return {
            "token": TokenSerializer(user.auth_token).data,
            "user": minimal_user_serializer.data,
        }
コード例 #5
0
ファイル: views.py プロジェクト: silasseB/wiplay-it-project
    def get_response_data(self, user):

        if allauth_settings.EMAIL_VERIFICATION == \
              allauth_settings.EmailVerificationMethod.MANDATORY:
            return {"detail": _("Verification e-mail sent.")}

        if getattr(settings, 'REST_USE_JWT', False):
            response_data = jwt_response_payload_handler(
                self.token, user, self.request)
            return response_data

        else:
            return TokenSerializer(user.auth_token).data
コード例 #6
0
ファイル: views.py プロジェクト: gbstech/covid19_backend
    def get_response_data(self, user):

        try:
            if getattr(settings, 'REST_USE_JWT', False):
                data = {'user': user, 'token': self.token}
                data = JWTSerializer(data).data
            else:
                data = TokenSerializer(user.auth_token).data

            data.update({'username': user.username})
            return data

        except:
            logger.error('sign up error {}'.format(traceback.format_exc()))
コード例 #7
0
    def get_response_data(self, user):
        if allauth_settings.EMAIL_VERIFICATION == \
                allauth_settings.EmailVerificationMethod.MANDATORY:
            return {"detail": _("Verification e-mail sent.")}

        if getattr(settings, 'REST_USE_JWT', False):
            data = {'user': user, 'token': self.token}
            return JWTSerializer(data).data
        else:
            #return TokenSerializer(user.auth_token).data
            orginal_response = TokenSerializer(user.auth_token).data
            print("ORIGINAL RESPONSE")
            print(orginal_response)
            #orginal_response = super().get_response()
            mydata = {
                "username": user.username,
                "email": user.email,
                "status": "ACTIVATE"
            }
            #current_site = get_current_site(request)
            message = render_to_string(
                'acc_active_email.html', {
                    'user': user,
                    'domain': 'current_site.domain',
                    'uid': user.pk,
                    'token': account_activation_token.make_token(user),
                })
            mail_subject = 'Activate your CIA account.'
            to_email = user.email
            email = EmailMessage(mail_subject, message, to=[to_email])
            email.send()
            print('MY DATA')
            print(mydata)
            orginal_response.update(mydata)
            print("ORIGINAL RESPONSE")
            print(orginal_response)
            return orginal_response
コード例 #8
0
    def get_response_data(self, user):
        """
            Here I added context to the return of each serializer so
            HyperlinkedIdentityFields would work for the user return
        """
        if allauth_settings.EMAIL_VERIFICATION == \
                allauth_settings.EmailVerificationMethod.MANDATORY:
            return {"detail": _("Verification e-mail sent.")}

        if getattr(settings, 'REST_USE_JWT', False):
            data = {'user': user, 'token': self.token}
            return JWTSerializer(data, context={'request': self.request}).data
        else:
            return TokenSerializer(user.auth_token,
                                   context={
                                       'request': self.request
                                   }).data
コード例 #9
0
    def get_response_data(self, user):
        if (
            allauth_settings.EMAIL_VERIFICATION
            == allauth_settings.EmailVerificationMethod.MANDATORY
        ):
            return {'detail': _('Verification e-mail sent.')}

        context = self.get_serializer_context()

        if getattr(settings, 'REST_USE_JWT', False):
            data = JWTSerializer(
                {'user': user, 'token': self.token}, context=context
            ).data
        else:
            data = TokenSerializer(user.auth_token, context=context).data

        radius_token = self.get_or_create_radius_token(user)
        data['radius_user_token'] = radius_token.key
        return data
コード例 #10
0
    def get_response_data(self, user):
        if allauth_settings.EMAIL_VERIFICATION == \
                allauth_settings.EmailVerificationMethod.MANDATORY:
            return {}

        return TokenSerializer(user.auth_token).data
コード例 #11
0
 def get_response_data(self, user):
     if auth_settings.EMAIL_VERIFICATION == \
             auth_settings.EmailVerificationMethod.MANDATORY:
         return {"detail": _("Verification e-mail sent.")}
     return TokenSerializer(user.auth_token).data
コード例 #12
0
 def get_response_data(self, user):
     # PROBLEM
     return TokenSerializer(user.auth_token).data