mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-23 02:27:05 +00:00
Fixed E721 (type-comparison): Use is
and is not
for type comparisons, or isinstance()
for isinstance checks
This commit is contained in:
parent
f0377dd59e
commit
cacf6d2006
@ -490,7 +490,7 @@ def totp_post_enable():
|
|||||||
secret = request.form.get('secret')
|
secret = request.form.get('secret')
|
||||||
token = request.form.get('token')
|
token = request.form.get('token')
|
||||||
label = request.form.get('label')
|
label = request.form.get('label')
|
||||||
if type(token) != str:
|
if not isinstance(token, str):
|
||||||
return ("Bad Input", 400)
|
return ("Bad Input", 400)
|
||||||
try:
|
try:
|
||||||
validate_totp_secret(secret)
|
validate_totp_secret(secret)
|
||||||
|
@ -68,7 +68,7 @@ def disable_mfa(email, mfa_id, env):
|
|||||||
return c.rowcount > 0
|
return c.rowcount > 0
|
||||||
|
|
||||||
def validate_totp_secret(secret):
|
def validate_totp_secret(secret):
|
||||||
if type(secret) != str or secret.strip() == "":
|
if not isinstance(secret, str) or secret.strip() == "":
|
||||||
msg = "No secret provided."
|
msg = "No secret provided."
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
if len(secret) != 32:
|
if len(secret) != 32:
|
||||||
|
Loading…
Reference in New Issue
Block a user