Пример #1
0
    def post(self, request):
        """User registration view."""
        email = request.data['email']
        #email = User.normalize_email(request.data['email'])
        if not email_is_valid(email):
            return Response("Please use a different email address provider.",
                            status=status.HTTP_200_OK)

        if User.objects.filter(email=email).exists():
            return Response(
                "Email already in use, please use a different email address.",
                status=status.HTTP_200_OK)

        now = timezone.now()

        user = User(email=email,
                    first_name=request.data['first_name'],
                    last_name=request.data['last_name'],
                    is_active=True,
                    last_login=now,
                    date_joined=now)
        user.set_password(request.data['password'])

        user.save()
        return Response("SUCCESS", status=status.HTTP_200_OK)
    def validate_email(self, value):
        """
        Validate if email is valid or there is an user using the email.

        :param value: string
        :return: string
        """

        if not email_is_valid(value):
            raise serializers.ValidationError('Please use a different email address provider.')

        return value
Пример #3
0
    def validate_email(self, value):
        """
        Validate if email is valid or there is an user using the email.

        :param value: string
        :return: string
        """

        if not email_is_valid(value):
            raise serializers.ValidationError(
                'Please use a different email address provider.')

        return value
Пример #4
0
    def validate_email(self, value):
        """
        Validate if email is valid or there is an user using the email.
        :param value: string
        :return: string
        """

        if not email_is_valid(value):
            raise serializers.ValidationError('Please use a different email address provider.')

        if User.objects.filter(email=value).exists():
            raise serializers.ValidationError('Email already in use, please use a different email address.')

        return value
    def validate_email(self, value):
        """
        Validate if email is valid or there is an user using the email.

        :param value: string
        :return: string
        """

        if not email_is_valid(value):
            raise serializers.ValidationError('Please use a different email address provider.')

        if User.objects.filter(email=value).exists():
            raise serializers.ValidationError('Email already in use, please use a different email address.')

        return value
Пример #6
0
    def validate_email(self, value):
        if not email_is_valid(value):
            raise serializers.ValidationError(
                'Please use a different email address provider.')

        return value