can change own password (actually working now)

This commit is contained in:
Ludovic Stephan 2017-01-07 13:32:05 -02:00
parent 2a20beeb59
commit fcf76b4af8

View file

@ -464,6 +464,7 @@ def account_update(request, trigramme):
account.refresh_from_db()
user_form = UserRestrictForm(request.POST, instance=account.user)
account_form = AccountRestrictForm(request.POST, instance=account)
pwd_form = AccountPwdForm(request.POST)
if user_form.is_valid() and account_form.is_valid():
user_form.save()
@ -472,6 +473,15 @@ def account_update(request, trigramme):
messages.success(request,
'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:
messages.error(request, 'Permission refusée')
if success: