Commit f312f03c authored by Michal Čihař's avatar Michal Čihař

Simplify conditions a bit

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 26b6569f
......@@ -455,23 +455,21 @@ def password(request):
do_change = False
if request.user.has_usable_password():
if request.method == 'POST':
if not request.user.has_usable_password():
do_change = True
change_form = None
elif request.method == 'POST':
change_form = PasswordChangeForm(request.POST)
if change_form.is_valid():
cur_password = change_form.cleaned_data['password']
if request.user.check_password(cur_password):
do_change = True
else:
do_change = request.user.check_password(cur_password)
if not do_change:
messages.error(
request,
_('You have entered an invalid password.')
)
else:
change_form = PasswordChangeForm()
else:
do_change = True
change_form = None
if request.method == 'POST':
form = PasswordForm(request.POST)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment