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

WIP: Use the user model as the email model. #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonathan-s
Copy link
Contributor

You can customize the user model so that the email
is the username, in cases like that it may be superflouous
to have multiple emails, in fact it may not be desirable.

For applications like that it's easier to only use the email
address defined in the user model.

Closes #347.

You can customize the user model so that the email
is the username, in cases like that it may be superflouous
to have multiple emails, in fact it may not be desirable.

For applications like that it's easier to only use the email
address defined in the user model.
@@ -334,9 +330,11 @@ def send(self, **kwargs):
current_site.domain,
reverse(settings.ACCOUNT_EMAIL_CONFIRMATION_URL, args=[self.key])
)

user = self.email_address.user if not user_as_email() else self
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
user = self.email_address.user if not user_as_email() else self
user = self.email_address.user if not user_as_email() else self.email_address


class EmailAddressManager(models.Manager):

def add_email(self, user, email, **kwargs):
confirm = kwargs.pop("confirm", False)
email_address = self.create(user=user, email=email, **kwargs)
if confirm and not email_address.verified:
email_address.send_confirmation()
self.send_confirmation(email=email)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.send_confirmation(email=email)
self.send_confirmation(email=email_address)

@paltman
Copy link
Contributor

paltman commented Nov 24, 2021

Not quite following this one but it is a pretty big change in how we consider email addresses with EmailAddress model and email confirmations and having multiple addresses, etc. I need to come back to this and try to grok the rationale here.

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

Successfully merging this pull request may close these issues.

Introduce option to use User.email instead of EmailAddress
2 participants