Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
7b24e550
Unverified
Commit
7b24e550
authored
Mar 28, 2017
by
Joost Rijneveld
Browse files
members: prevent errors for hidden password field
parent
280153a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/members/forms.py
View file @
7b24e550
...
...
@@ -28,6 +28,11 @@ class UserCreationForm(BaseUserCreationForm):
# Don't forget to edit the formset in admin.py!
# This is a stupid quirk of the user admin.
# shadow the password fields to prevent validation errors,
# since we generate the passwords dynamically.
password1
=
None
password2
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
for
field
in
(
'email'
,
'first_name'
,
'last_name'
):
...
...
@@ -47,6 +52,8 @@ class UserCreationForm(BaseUserCreationForm):
def
save
(
self
,
commit
=
True
):
password
=
User
.
objects
.
make_random_password
(
length
=
15
)
# pass the password on as if it was filled in, so that save() works
self
.
cleaned_data
[
'password1'
]
=
password
user
=
super
().
save
(
commit
=
False
)
user
.
set_password
(
password
)
if
commit
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment