mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
fix(admin): a new user's password reaches the database only hashed
The admin page that creates a user saved the form first, which wrote the user with the raw password in the password column, and hashed it with a second save afterwards. The raw password was in the database, and in its journal and any copy taken meanwhile, and stayed there if anything failed between the two writes. - UserCreateForm hashes the password before the first save; groups and permissions are saved as before. - The form applies AUTH_PASSWORD_VALIDATORS, after the user fields are set (so the similarity check sees the new username), as the password change forms already did. The settings template configures no validators, so nothing changes unless an installation sets them. The tests record the SQL parameters of the request: the previous code wrote the raw password in the INSERT; it also accepted passwords that configured validators reject.
This commit is contained in:
parent
731d14efd7
commit
405e6f1445
3 changed files with 88 additions and 3 deletions
|
|
@ -95,9 +95,6 @@ def user_create(request):
|
|||
attributes_form = forms.UserAttributesForm(request.POST or None)
|
||||
if user_form.is_valid() and attributes_form.is_valid():
|
||||
user = user_form.save()
|
||||
password = user_form.cleaned_data["password"]
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
attributes = attributes_form.save(commit=False)
|
||||
attributes.user = user
|
||||
attributes.save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue