mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-04-15 23:47:24 +02:00
Fixed EM101 (raw-string-in-exception): Exception must not use a string literal, assign to variable first
This commit is contained in:
committed by
Joshua Tauberer
parent
49124cc9ca
commit
dd61844ced
@@ -41,9 +41,11 @@ def enable_mfa(email, type, secret, token, label, env):
|
||||
# Sanity check with the provide current token.
|
||||
totp = pyotp.TOTP(secret)
|
||||
if not totp.verify(token, valid_window=1):
|
||||
raise ValueError("Invalid token.")
|
||||
msg = "Invalid token."
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
raise ValueError("Invalid MFA type.")
|
||||
msg = "Invalid MFA type."
|
||||
raise ValueError(msg)
|
||||
|
||||
conn, c = open_database(env, with_connection=True)
|
||||
c.execute('INSERT INTO mfa (user_id, type, secret, label) VALUES (?, ?, ?, ?)', (get_user_id(email, c), type, secret, label))
|
||||
@@ -67,9 +69,11 @@ def disable_mfa(email, mfa_id, env):
|
||||
|
||||
def validate_totp_secret(secret):
|
||||
if type(secret) != str or secret.strip() == "":
|
||||
raise ValueError("No secret provided.")
|
||||
msg = "No secret provided."
|
||||
raise ValueError(msg)
|
||||
if len(secret) != 32:
|
||||
raise ValueError("Secret should be a 32 characters base32 string")
|
||||
msg = "Secret should be a 32 characters base32 string"
|
||||
raise ValueError(msg)
|
||||
|
||||
def provision_totp(email, env):
|
||||
# Make a new secret.
|
||||
|
||||
Reference in New Issue
Block a user