From b05daecd282f725da3afe4c9a680619c06d33fab Mon Sep 17 00:00:00 2001 From: Son NK Date: Mon, 9 Mar 2020 09:17:40 +0100 Subject: [PATCH] Handle unsign can generate other exceptions --- app/api/views/auth_mfa.py | 2 +- app/dashboard/views/mailbox.py | 3 ++- app/dashboard/views/mailbox_detail.py | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/views/auth_mfa.py b/app/api/views/auth_mfa.py index abb686ac..c53a0b9c 100644 --- a/app/api/views/auth_mfa.py +++ b/app/api/views/auth_mfa.py @@ -38,7 +38,7 @@ def auth_mfa(): s = Signer(FLASK_SECRET) try: user_id = int(s.unsign(mfa_key)) - except BadSignature: + except Exception: return jsonify(error="Invalid mfa_key"), 400 user = User.get(user_id) diff --git a/app/dashboard/views/mailbox.py b/app/dashboard/views/mailbox.py index 1f805dc5..330b7ae7 100644 --- a/app/dashboard/views/mailbox.py +++ b/app/dashboard/views/mailbox.py @@ -142,8 +142,9 @@ def mailbox_verify(): try: r_id = int(s.unsign(mailbox_id)) - except BadSignature: + except Exception: flash("Invalid link. Please delete and re-add your mailbox", "error") + return redirect(url_for("dashboard.mailbox_route")) else: mailbox = Mailbox.get(r_id) mailbox.verified = True diff --git a/app/dashboard/views/mailbox_detail.py b/app/dashboard/views/mailbox_detail.py index 82ce0657..cd4effc6 100644 --- a/app/dashboard/views/mailbox_detail.py +++ b/app/dashboard/views/mailbox_detail.py @@ -156,7 +156,7 @@ def mailbox_confirm_change_route(): try: r_id = int(s.unsign(mailbox_id)) - except BadSignature: + except Exception: flash("Invalid link", "error") return redirect(url_for("dashboard.index")) else: @@ -179,4 +179,3 @@ def mailbox_confirm_change_route(): else: flash("Invalid link", "error") return redirect(url_for("dashboard.index")) -