-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat(account): Move RequestPasswordReset.save impl into account adapter #4034
feat(account): Move RequestPasswordReset.save impl into account adapter #4034
Conversation
e1258a0
to
6bc0f43
Compare
d633579
to
1c3c049
Compare
@pennersr would it be possible to get this one reviewed while you're at it? |
Must admit, I am still a bit at odds on how to proceed here. #4027 is starting to look more attractive given the impact of the change in this PR. WDYT? |
ec0f03d
to
27910e1
Compare
I think I was able to improve this PR significantly after your review feedback - let me if the changes sway your opinion. I'm also fine w/ #4027. If we go that route, would you want to also expand/extend #4027 to include the other forms with the ✅ in my comment here while we're at it? |
372e22a
to
6c6ae8a
Compare
@pennersr ping 😄 |
allauth/account/adapter.py
Outdated
@@ -563,9 +563,20 @@ def is_safe_url(self, url): | |||
|
|||
return url_has_allowed_host_and_scheme(url, allowed_hosts=allowed_hosts) | |||
|
|||
def request_password_reset(self, users): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts:
- Naming -- it does not request the password reset
- Behavior -- if you filter users here the emails are silently skipped which is not very obvious.
Wouldn't it make be more useful to add this method to the adapter?:
def send_password_reset_mail(self, user, email)
Then, you are free to implement that as you see fit (send real reset, skip the mail, or send another mail).
6c6ae8a
to
35a6aac
Compare
|
||
def _send_password_reset_mail(self, request, email, users, **kwargs): | ||
adapter: DefaultAccountAdapter = get_adapter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to either abort the method inside the if
above by returning return email
, or, to reintroduce the else
. As is now, both cases are executed (the if and the else part), and while that works because users
is empty it did trip me over while reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch though!
This new adapter method can be used to apply custom logic regarding whether a user should be able to initiate the reset password flow.
35a6aac
to
f03eed7
Compare
Related to #4024.