Browse Source

FIXBUG: поправил изменение пароля

devel
bashmak 9 years ago
parent
commit
18bea3eb48
  1. 6
      accounts_app/locale/ru/LC_MESSAGES/django.po
  2. 16
      accounts_app/views.py

6
accounts_app/locale/ru/LC_MESSAGES/django.po

@ -184,3 +184,9 @@ msgstr "Редактировать"
msgid "Set a task"
msgstr "Дать задачу"
msgid "Empty password, fill it"
msgstr "Пустой пароль, впишите что-то в пароль"
msgid "New password is empty, fill it"
msgstr "Новый пароль пустой, придумайте себе пароль"

16
accounts_app/views.py

@ -4,7 +4,6 @@ from django.contrib.auth import authenticate, login, logout
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import NoReverseMatch
from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.http import Http404
from django.contrib.auth.models import Group, Permission
from django.contrib import messages
from django.utils.translation import ugettext as _
@ -129,14 +128,21 @@ def ch_info(request):
user.telephone = request.POST.get('telephone')
psw = request.POST.get('oldpasswd')
if psw != '':
if psw != '' and psw is not None:
if user.check_password(psw):
newpasswd = request.POST.get('newpasswd')
user.set_password(newpasswd)
if newpasswd != '' and newpasswd is not None:
user.set_password(newpasswd)
user.save()
request.user = user
logout(request)
return redirect('acc_app:other_profile', uid=user.pk)
else:
messages.error(request, _('New password is empty, fill it'))
else:
messages.error(request, _('Wrong password'))
user.save()
request.user = user
else:
messages.warning(request, _('Empty password, fill it'))
return render(request, 'accounts/settings/ch_info.html', {
'user': request.user

Loading…
Cancel
Save