8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

Merge branch 'fix_initial_serviceuser' into 'dev'

Fix initial password for serviceuser

See merge request federez/re2o!366
This commit is contained in:
klafyvel 2018-12-22 21:46:39 +01:00
commit 965ec1ab69

View file

@ -492,13 +492,14 @@ class PasswordForm(FormRevMixin, ModelForm):
class ServiceUserForm(FormRevMixin, ModelForm): class ServiceUserForm(FormRevMixin, ModelForm):
""" Modification d'un service user""" """Service user creation
force initial password set"""
password = forms.CharField( password = forms.CharField(
label=_("New password"), label=_("New password"),
max_length=255, max_length=255,
validators=[MinLengthValidator(8)], validators=[MinLengthValidator(8)],
widget=forms.PasswordInput, widget=forms.PasswordInput,
required=False required=True
) )
class Meta: class Meta:
@ -510,7 +511,7 @@ class ServiceUserForm(FormRevMixin, ModelForm):
super(ServiceUserForm, self).__init__(*args, prefix=prefix, **kwargs) super(ServiceUserForm, self).__init__(*args, prefix=prefix, **kwargs)
def save(self, commit=True): def save(self, commit=True):
"""Changement du mot de passe""" """Password change"""
user = super(ServiceUserForm, self).save(commit=False) user = super(ServiceUserForm, self).save(commit=False)
if self.cleaned_data['password']: if self.cleaned_data['password']:
user.set_password(self.cleaned_data.get("password")) user.set_password(self.cleaned_data.get("password"))
@ -520,6 +521,14 @@ class ServiceUserForm(FormRevMixin, ModelForm):
class EditServiceUserForm(ServiceUserForm): class EditServiceUserForm(ServiceUserForm):
"""Formulaire d'edition de base d'un service user. Ne permet """Formulaire d'edition de base d'un service user. Ne permet
d'editer que son group d'acl et son commentaire""" d'editer que son group d'acl et son commentaire"""
password = forms.CharField(
label=_("New password"),
max_length=255,
validators=[MinLengthValidator(8)],
widget=forms.PasswordInput,
required=False
)
class Meta(ServiceUserForm.Meta): class Meta(ServiceUserForm.Meta):
fields = ['access_group', 'comment'] fields = ['access_group', 'comment']