1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-05-27 06:28:58 +02:00

Fixed EM101 (raw-string-in-exception): Exception must not use a string literal, assign to variable first

This commit is contained in:
Teal Dulcet
2023-12-22 07:10:48 -08:00
committed by Joshua Tauberer
parent 49124cc9ca
commit dd61844ced
7 changed files with 42 additions and 21 deletions

View File

@@ -49,10 +49,12 @@ class AuthService:
username, password = parse_http_authorization_basic(request.headers.get('Authorization', ''))
if username in {None, ""}:
raise ValueError("Authorization header invalid.")
msg = "Authorization header invalid."
raise ValueError(msg)
if username.strip() == "" and password.strip() == "":
raise ValueError("No email address, password, session key, or API key provided.")
msg = "No email address, password, session key, or API key provided."
raise ValueError(msg)
# If user passed the system API key, grant administrative privs. This key
# is not associated with a user.
@@ -72,7 +74,8 @@ class AuthService:
# If no password was given, but a username was given, we're missing some information.
elif password.strip() == "":
raise ValueError("Enter a password.")
msg = "Enter a password."
raise ValueError(msg)
else:
# The user is trying to log in with a username and a password
@@ -114,7 +117,8 @@ class AuthService:
])
except:
# Login failed.
raise ValueError("Incorrect email address or password.")
msg = "Incorrect email address or password."
raise ValueError(msg)
# If MFA is enabled, check that MFA passes.
status, hints = validate_auth_mfa(email, request, env)