users: Add email address field during first boot

- Mostly because administrators won't discover the email address field for the
user later on.

- This field is important to be able to run 'reset password' operation.

Tests:

- In stable and testing containers, run first boot wizard. Enter the email
address during the first boot and see that it was saved as part of user account.
Leave the email address blank and it is possible to proceed. User account show
blank email address.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2024-03-14 21:58:04 +02:00
1 parent 9d2a11b874
commit 1b09d01575
1 file changed
+8 -1
+8 -1
View File
@@ -382,11 +382,16 @@ class UserChangePasswordForm(PasswordConfirmForm, SetPasswordForm):
return user
class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
class FirstBootForm(ValidNewUsernameCheckMixin, EmailFieldMixin,
auth.forms.UserCreationForm):
"""User module first boot step: create a new admin user."""
username = USERNAME_FIELD
class Meta(UserCreationForm.Meta):
"""Metadata to control automatic form building."""
fields = ('username', 'email', 'password1')
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
@@ -399,6 +404,8 @@ class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
"""Create and log the user in."""
user = super().save(commit=commit)
if commit:
self.save_m2m() # Django 3.x does not call save_m2m()
first_boot.mark_step_done('users_firstboot')
try: