Fix encodage password

This commit is contained in:
Aurélien Delobelle 2016-09-06 15:30:51 +02:00
parent 58cb6015fc
commit 5569b7d154
2 changed files with 2 additions and 2 deletions

View file

@ -18,7 +18,7 @@ class KFetBackend(object):
return None return None
try: try:
password_sha256 = hashlib.sha256(password.encode()).hexdigest() password_sha256 = hashlib.sha256(password.encode('utf-8')).hexdigest()
account = Account.objects.get(password=password_sha256) account = Account.objects.get(password=password_sha256)
user = account.cofprofile.user user = account.cofprofile.user
except Account.DoesNotExist: except Account.DoesNotExist:

View file

@ -399,7 +399,7 @@ def account_update(request, trigramme):
if (request.user.has_perm('kfet.change_account_password') if (request.user.has_perm('kfet.change_account_password')
and pwd_form.is_valid()): and pwd_form.is_valid()):
pwd = pwd_form.cleaned_data['pwd1'] pwd = pwd_form.cleaned_data['pwd1']
pwd_sha256 = hashlib.sha256(pwd.encode()).hexdigest() pwd_sha256 = hashlib.sha256(pwd.encode('utf-8')).hexdigest()
Account.objects.filter(pk=account.pk).update( Account.objects.filter(pk=account.pk).update(
password = pwd_sha256) password = pwd_sha256)
messages.success(request, 'Mot de passe mis à jour') messages.success(request, 'Mot de passe mis à jour')