Fixed: Error 500 on password change when old password didn't match.

This commit is contained in:
s3lph 2019-02-08 04:53:45 +01:00
parent 229597f436
commit d607495e4b

View file

@ -10,7 +10,7 @@ from matemat.webserver import pagelet, RequestArguments, PageletResponse, Redire
from matemat.util.currency_format import parse_chf
from matemat.db import MatematDatabase
from matemat.db.primitives import User, ReceiptPreference
from matemat.exceptions import DatabaseConsistencyError, HttpException
from matemat.exceptions import AuthenticationError, DatabaseConsistencyError, HttpException
@pagelet('/admin')
@ -101,7 +101,10 @@ def handle_change(args: RequestArguments, user: User, db: MatematDatabase, confi
if newpass != newpass2:
raise ValueError('New passwords don\'t match')
# Write the new password to the database
db.change_password(user, oldpass, newpass)
try:
db.change_password(user, oldpass, newpass)
except AuthenticationError:
raise ValueError('Old password doesn\'t match')
# The user requested a touchkey change
elif change == 'touchkey':