mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Make send_confirm_email_if_necessary clearer
This commit is contained in:
parent
5fdb8a7b1e
commit
154096050c
1 changed files with 16 additions and 8 deletions
|
@ -800,23 +800,31 @@ class User(
|
||||||
return
|
return
|
||||||
|
|
||||||
def send_confirm_email_if_necessary(self, request):
|
def send_confirm_email_if_necessary(self, request):
|
||||||
"""Update the user's email state
|
"""Update the user's email state:
|
||||||
|
* If the user changed email, it needs to be confirmed
|
||||||
|
* If they're not fully archived, send a confirmation email
|
||||||
|
|
||||||
Returns whether an email was sent"""
|
Returns whether an email was sent"""
|
||||||
# Only update the state if the email changed
|
# Only update the state if the email changed
|
||||||
if self.__original_email == self.email:
|
if self.__original_email == self.email:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.email_state = self.EMAIL_STATE_PENDING
|
# If the user was previously in the PENDING or UNVERIFIED state,
|
||||||
|
# we can't update email_change_date otherwise it would push back
|
||||||
|
# their due date
|
||||||
|
# However, if the user is in the VERIFIED state, we reset the date
|
||||||
|
if self.email_state == self.EMAIL_STATE_VERIFIED:
|
||||||
|
self.email_change_date = timezone.now()
|
||||||
|
|
||||||
# Fully archived users shouldn't get an email
|
# Remember that the user needs to confirm their email address again
|
||||||
|
self.email_state = self.EMAIL_STATE_PENDING
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
# Fully archived users shouldn't get an email, so stop here
|
||||||
if self.state == self.STATE_FULL_ARCHIVE:
|
if self.state == self.STATE_FULL_ARCHIVE:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Don't allow users without a confirmed email to postpone their due date
|
# Send the email
|
||||||
if self.email_state == self.EMAIL_STATE_VERIFIED or not self.email_change_date:
|
|
||||||
self.email_change_date = timezone.now()
|
|
||||||
|
|
||||||
self.save()
|
|
||||||
self.confirm_email_address_mail(request)
|
self.confirm_email_address_mail(request)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue