From 832b34fc54f3a30a7250a8ab94e157d82c16b7e7 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Fri, 1 May 2020 12:00:45 +0200 Subject: [PATCH] Improved errorhandling for resending password Improved errorhandling for editing user --- cps/admin.py | 3 +++ cps/helper.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cps/admin.py b/cps/admin.py index 795bccb8..5cec8e26 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -817,6 +817,9 @@ def update_mailsettings(): @admin_required def edit_user(user_id): content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User + if not content: + flash(_(u"User not found"), category="error") + return redirect(url_for('admin.admin')) downloads = list() languages = speaking_language() translations = babel.list_translations() + [LC('en')] diff --git a/cps/helper.py b/cps/helper.py index 4eebba55..435b1322 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -447,6 +447,8 @@ def delete_book_gdrive(book, book_format): def reset_password(user_id): existing_user = ub.session.query(ub.User).filter(ub.User.id == user_id).first() + if not existing_user: + return 0, None password = generate_random_password() existing_user.password = generate_password_hash(password) if not config.get_mail_server_configured():