8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Require login on confirmation email resend

This commit is contained in:
Jean-Romain Garnier 2020-04-17 11:39:11 +00:00 committed by Gabriel Detraz
parent 32c1f8d50a
commit e574284936
2 changed files with 8 additions and 3 deletions

View file

@ -330,7 +330,11 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
self.fields["room"].label = _("Room") self.fields["room"].label = _("Room")
self.fields["room"].empty_label = _("No room") self.fields["room"].empty_label = _("No room")
self.fields["school"].empty_label = _("Select a school") self.fields["school"].empty_label = _("Select a school")
self.initial["email"] = kwargs["instance"].email
if not kwargs["user"].is_anonymous():
self.initial["email"] = kwargs["user"].email
else:
self.initial["email"] = None
class Meta: class Meta:
model = Adherent model = Adherent
@ -383,7 +387,7 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"""On met à jour l'état de l'utilisateur en fonction de son mail""" """On met à jour l'état de l'utilisateur en fonction de son mail"""
user = super(AdherentForm, self).save(commit=commit) user = super(AdherentForm, self).save(commit=commit)
if user.email != self.initial["email"]: if self.initial["email"] is not None and user.email != self.initial["email"]:
# Send a confirmation email # Send a confirmation email
if user.state in [User.STATE_ACTIVE, User.STATE_DISABLED, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED]: if user.state in [User.STATE_ACTIVE, User.STATE_DISABLED, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED]:
user.state = User.STATE_EMAIL_NOT_YET_CONFIRMED user.state = User.STATE_EMAIL_NOT_YET_CONFIRMED

View file

@ -1051,8 +1051,9 @@ def process_email(request, req):
) )
@login_required
@can_edit(User) @can_edit(User)
def resend_confirmation_email(request, userid): def resend_confirmation_email(request, logged_user, userid):
""" Renvoi du mail de confirmation """ """ Renvoi du mail de confirmation """
try: try:
user = User.objects.get( user = User.objects.get(