From 4791c2fc620203807cd8ab0a40fdabc6fd469aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Sun, 6 Sep 2020 13:03:54 +0200 Subject: [PATCH] Safeguard against empty mru_token column * hmac.compare_digest() expects arguments of type string, make sure we don't pass None * Currently, this cannot happen but we might not want to store `mru_token` during setup --- management/mailconfig.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/management/mailconfig.py b/management/mailconfig.py index 491a4d5c..6e31eae8 100755 --- a/management/mailconfig.py +++ b/management/mailconfig.py @@ -557,10 +557,12 @@ def get_mfa_state(email, env): if credential_row is None: return { 'type': None } + secret, mru_token = credential_row + return { 'type': 'totp', - 'secret': credential_row[0], - 'mru_token': credential_row[1] + 'secret': secret, + 'mru_token': '' if mru_token is None else mru_token } def create_totp_credential(email, secret, token, env):