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

Reset password for user who registered with Social Auth (Google) #758

Open
AyushBhardwaj321 opened this issue Aug 23, 2023 · 3 comments
Open

Comments

@AyushBhardwaj321
Copy link

Hello,
I am trying to using custom model with Djoser JWT endpoint but I want to reset the password for those user who register with Google OAuth.
When I am using the API endpoint the password reset mail is not getting send to mail.

Any suggestion is appreciated.

@Oscurodrago
Copy link

i have same very similar,
Google login works, it's create correctly user and also JWT token can be created ,
but when i try to reset password through send email, response says ["User with given email does not exist."]

note. if account is created with user_create by djoser they can reset password w/o problems

@Oscurodrago
Copy link

just saw around
seem the problem is the missing password and amost all guides online points to one wrong solution to use djoser
to avoid that problem just add a random pass when is None

`class UserManager(BaseUserManager):

def create_user(self, email,  password=None, **kwargs):
    if not email:
        raise ValueError("Users must have an email address")
    email = self.normalize_email(email)
    user = self.model(email=email, **kwargs)
    if(password is None):
        password = get_random_string(10)
    user.set_password(password)
    user.is_active = True
    user.save()

    return user`

@tomwojcik
Copy link
Contributor

Thanks for the report. Please create a failing test case.

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

No branches or pull requests

3 participants