Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't login without email even though it's supposed to be optional #644

Open
Mutusen opened this issue Jun 29, 2021 · 0 comments
Open

Can't login without email even though it's supposed to be optional #644

Mutusen opened this issue Jun 29, 2021 · 0 comments

Comments

@Mutusen
Copy link

Mutusen commented Jun 29, 2021

Hi, the documentation says "Optional either username or email can be used, or both. It returns response with token along with it for authentication" but it doesn't work if I don't provide an email address.

In api/serializers.py:

class UserLoginSerializer(serializers.Serializer):
    email = serializers.EmailField(required=False)
    username = serializers.CharField(required=False)
    password = serializers.CharField()
    def validate(self, data):
        email = data['email']
        if not 'email' in data and not 'username' in data :
            raise serializers.ValidationError('Enter Username Or Email')        
        return data

I suggest deleting the line email = data['email'] because the email variable is not used in this function and causes an error if there is no email given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant