Add "old email address" field

This commit is contained in:
Mira Weller
2025-09-30 15:15:36 +02:00
parent 5512fa8245
commit b5ad68f48d
3 changed files with 7 additions and 0 deletions
+1
View File
@@ -190,6 +190,7 @@ class UserEmailChangeForm(forms.Form):
'duplicate_identifier': _("There already is an account associated with this email address. "
"Please choose a different one."),
}
old_email = forms.EmailField(label=_('Old email address'), disabled=True)
new_email = forms.EmailField(label=_('New email address'))
def __init__(self, *args, **kwargs):
@@ -12,6 +12,7 @@
<p class="text-muted">
{% trans "This changes the email address used to login to your account, as well as where we send email notifications." %}
</p>
{% bootstrap_field form.old_email %}
{% bootstrap_field form.new_email %}
<p>
{% trans "We will send a confirmation code to your new email address, which you need to enter in the next step to confirm the email address is correct." %}
+5
View File
@@ -864,6 +864,11 @@ class UserEmailChangeView(RecentAuthenticationRequiredMixin, FormView):
"user": self.request.user,
}
def get_initial(self):
return {
"old_email": self.request.user.email
}
def form_valid(self, form):
self.request.user.send_confirmation_code('email_change', form.cleaned_data['new_email'])
return redirect(reverse('control:user.settings.email.confirm', kwargs={}))