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

Add documentation for customizing the fields for authentication #38

Open
LucasCTN opened this issue Oct 31, 2023 · 2 comments
Open

Add documentation for customizing the fields for authentication #38

LucasCTN opened this issue Oct 31, 2023 · 2 comments

Comments

@LucasCTN
Copy link

I'm having a hard time trying to change the username field to become email, and use it for validation instead. It would be useful to have a tutorial for making modifications like these in the docs.

I thought it would be on customizing_token_claims.md, but it just adds the field without validating it, and username is still required.

@pedrohsbarbosa99
Copy link

@LucasCTN I think you need customize your User model like descibe at django documentation:
https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD

for example:

class MyUser(AbstractBaseUser):
    email = models.EmailField(_("email address"), max_length=255, unique=True)
     ...
    USERNAME_FIELD = "email"

Maybe I'm wrong but I think it's not a customization from django ninja jwt but of django.

@LucasCTN
Copy link
Author

LucasCTN commented Nov 1, 2023

@LucasCTN I think you need customize your User model like descibe at django documentation: https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD

for example:

class MyUser(AbstractBaseUser):
    email = models.EmailField(_("email address"), max_length=255, unique=True)
     ...
    USERNAME_FIELD = "email"

Maybe I'm wrong but I think it's not a customization from django ninja jwt but of django.

Oh, you are right! My apologies, I presumed I would need to customize the authentication.

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

2 participants