forked from DGNum/gestioCOF
can change own password (actually working now)
This commit is contained in:
parent
2a20beeb59
commit
fcf76b4af8
1 changed files with 10 additions and 0 deletions
|
@ -464,6 +464,7 @@ def account_update(request, trigramme):
|
||||||
account.refresh_from_db()
|
account.refresh_from_db()
|
||||||
user_form = UserRestrictForm(request.POST, instance=account.user)
|
user_form = UserRestrictForm(request.POST, instance=account.user)
|
||||||
account_form = AccountRestrictForm(request.POST, instance=account)
|
account_form = AccountRestrictForm(request.POST, instance=account)
|
||||||
|
pwd_form = AccountPwdForm(request.POST)
|
||||||
|
|
||||||
if user_form.is_valid() and account_form.is_valid():
|
if user_form.is_valid() and account_form.is_valid():
|
||||||
user_form.save()
|
user_form.save()
|
||||||
|
@ -472,6 +473,15 @@ def account_update(request, trigramme):
|
||||||
messages.success(request,
|
messages.success(request,
|
||||||
'Vos informations ont été mises à jour')
|
'Vos informations ont été mises à jour')
|
||||||
|
|
||||||
|
if pwd_form.is_valid():
|
||||||
|
pwd = pwd_form.cleaned_data['pwd1']
|
||||||
|
pwd_sha256 = hashlib.sha256(pwd.encode('utf-8'))\
|
||||||
|
.hexdigest()
|
||||||
|
Account.objects.filter(pk=account.pk).update(
|
||||||
|
password=pwd_sha256)
|
||||||
|
messages.success(
|
||||||
|
request, 'Votre mot de passe a été mis à jour')
|
||||||
|
|
||||||
if missing_perm:
|
if missing_perm:
|
||||||
messages.error(request, 'Permission refusée')
|
messages.error(request, 'Permission refusée')
|
||||||
if success:
|
if success:
|
||||||
|
|
Loading…
Reference in a new issue