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
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)
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
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, }
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
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()))
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
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
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
def get_response_data(self, user): if allauth_settings.EMAIL_VERIFICATION == \ allauth_settings.EmailVerificationMethod.MANDATORY: return {} return TokenSerializer(user.auth_token).data
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
def get_response_data(self, user): # PROBLEM return TokenSerializer(user.auth_token).data