Skip to content
This repository was archived by the owner on Apr 25, 2021. It is now read-only.
This repository was 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

Description

@mapes911

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions