-
Notifications
You must be signed in to change notification settings - Fork 461
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
Comments
i have same very similar, note. if account is created with user_create by djoser they can reset password w/o problems |
just saw around `class UserManager(BaseUserManager):
|
Thanks for the report. Please create a failing test case. |
When signing up using Google SSO, an unusable password is set for the user. This behavior is implemented by the To bypass this, if you have a custom |
Here's my implementation which fixes the issue: serializers.pyfrom django.contrib.auth import get_user_model
from djoser.serializers import SendEmailResetSerializer as BaseSendEmailResetSerializer
UserModel = get_user_model()
class SendEmailResetSerializer(BaseSendEmailResetSerializer):
def get_user(self, is_active: bool = True) -> UserModel | None: # noqa: FBT001, FBT002
try:
# Disable the user.has_usable_password() check to allow users registered via
# social auth to reset their password
return UserModel._default_manager.get( # noqa: SLF001
is_active=is_active,
**{self.email_field: self.data.get(self.email_field, "")},
)
except UserModel.DoesNotExist:
pass
if (
settings.PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND is True
or settings.USERNAME_RESET_SHOW_EMAIL_NOT_FOUND is True
):
self.fail("email_not_found")
return None settings.py
|
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.
The text was updated successfully, but these errors were encountered: