Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

JWT always created with user.username and not with USERNAME_FIELD #8

Open
mapes911 opened this issue May 24, 2020 · 0 comments
Open

Comments

@mapes911
Copy link

I ran into an issue where the login_required decorator was always saying that the user was not logged in. After some debugging I realized that it was because I had changed my user model to use email as the USERNAME_FIELD rather than username.

My username was always set to null, so when the JWT was created on this line:

https://github.com/binarytree-software/django-ariadne-jwt/blob/master/django_ariadne_jwt/utils.py#L74

the token created didn't have a user identifier in it.

I was able to get around that by adding this to my user model.

    @property
    def username(self):
        return self.email

Would be great if we could tell the library if we aren't using "username". Or if it could just use the USERNAME_FIELD from the user model.

Thanks!

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

No branches or pull requests

1 participant