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
Custom account email verification through adapter #1946 #3648
base: main
Are you sure you want to change the base?
Custom account email verification through adapter #1946 #3648
Conversation
scope = set(super(AuthentiqProvider, self).get_scope(request)) | ||
scope.add("openid") | ||
|
||
if Scope.EMAIL in scope: | ||
modifiers = "" | ||
if app_settings.EMAIL_REQUIRED: | ||
modifiers += "r" | ||
if app_settings.EMAIL_VERIFICATION: | ||
#TODO: How to get user email here for get_email_verification_method ? |
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.
How can I get user's email in this method to pass it to get_email_verification_method ?
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.
This method is called to get a list of scopes to ask permission for as part of the OAuth handshake. So, at this point in time you do not know what user is going to be authenticated, yet.
allauth/account/adapter.py
Outdated
@@ -752,6 +752,9 @@ def get_reauthentication_methods(self, user): | |||
) | |||
return ret | |||
|
|||
def get_email_verification_method(self, email=None): |
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.
def get_email_verification_method(self, email=None): | |
def get_email_verification_method(self, login): |
Now that we have a Login
class representing the current login, I think it is more useful to base this method on an instance of that. See:
https://github.com/pennersr/django-allauth/blob/main/allauth/account/utils.py#L158
So, for that to happen, I think we need to:
- For every case where the default value (
email_verification=app_settings.EMAIL_VERIFICATION
) is passed, passNone
. Then, inside the__init__
ofLogin
, when the email verification is not explicitly set to a value, call this adapter method.
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.
Thank you for reviewing I'll work on it.
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.
In assess_unique_email method https://github.com/pennersr/django-allauth/blob/main/allauth/account/utils.py#L496
We only have access to email not the Login instance as it is called before we complete signup.
Is it a good idea to keep both login and email ? or login can be None in this scenario ?
…dded for social account pennersr#1946
Submitting Pull Requests
General
Examples:
"fix(google): Fixed foobar bug"
,"feat(accounts): Added foobar feature"
.ChangeLog.rst
.AUTHORS
.Provider Specifics
N/A
test_settings.py::INSTALLED_APPS
anddocs/installation.rst::INSTALLED_APPS
.docs/providers/<provider name>.rst
anddocs/providers/index.rst
Provider Specifics toctree.docs/overview.rst
.