Added support for password migration

This commit is contained in:
Marc 2014-10-24 10:47:59 +00:00
parent 5ca9215303
commit 3b435bb655
2 changed files with 3 additions and 1 deletions

View file

@ -8,6 +8,7 @@ ACCOUNTS_TYPES = getattr(settings, 'ACCOUNTS_TYPES', (
('CUSTOMER', _("Customer")), ('CUSTOMER', _("Customer")),
('COMPANY', _("Company")), ('COMPANY', _("Company")),
('PUBLICBODY', _("Public body")), ('PUBLICBODY', _("Public body")),
('STAFF', _("Staff")),
)) ))
ACCOUNTS_DEFAULT_TYPE = getattr(settings, 'ACCOUNTS_DEFAULT_TYPE', 'INDIVIDUAL') ACCOUNTS_DEFAULT_TYPE = getattr(settings, 'ACCOUNTS_DEFAULT_TYPE', 'INDIVIDUAL')

View file

@ -51,6 +51,7 @@ class UserCreationForm(forms.ModelForm):
super(UserCreationForm, self).__init__(*args, **kwargs) super(UserCreationForm, self).__init__(*args, **kwargs)
if settings.ORCHESTRA_MIGRATION_MODE: if settings.ORCHESTRA_MIGRATION_MODE:
self.fields['password1'].widget = forms.TextInput(attrs={'size':'130'}) self.fields['password1'].widget = forms.TextInput(attrs={'size':'130'})
self.fields['password1'].help_text = _("RAW password digest (migration mode is enabled).")
self.fields['password2'].widget = forms.HiddenInput() self.fields['password2'].widget = forms.HiddenInput()
self.fields['password2'].required = False self.fields['password2'].required = False
@ -78,7 +79,7 @@ class UserCreationForm(forms.ModelForm):
def save(self, commit=True): def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False) user = super(UserCreationForm, self).save(commit=False)
if not settings.ORCHESTRA_MIGRATION_MODE: if settings.ORCHESTRA_MIGRATION_MODE:
user.password = self.cleaned_data['password1'] user.password = self.cleaned_data['password1']
else: else:
user.set_password(self.cleaned_data['password1']) user.set_password(self.cleaned_data['password1'])