MCPcopy Create free account
hub / github.com/lesspass/lesspass / UserCreationForm

Class UserCreationForm

containers/backend/api/admin.py:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class UserCreationForm(forms.ModelForm):
13 password1 = forms.CharField(label="Password", widget=forms.PasswordInput)
14 password2 = forms.CharField(
15 label="Password confirmation", widget=forms.PasswordInput
16 )
17
18 class Meta:
19 model = LessPassUser
20 fields = ("email",)
21
22 def clean_password2(self):
23 password1 = self.cleaned_data.get("password1")
24 password2 = self.cleaned_data.get("password2")
25 if password1 and password2 and password1 != password2:
26 raise forms.ValidationError("Passwords don't match")
27 return password2
28
29 def save(self, commit=True):
30 user = super(UserCreationForm, self).save(commit=False)
31 user.set_password(self.cleaned_data["password1"])
32 if commit:
33 user.save()
34 return user
35
36
37class UserChangeForm(forms.ModelForm):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected