mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 12:58:04 +00:00
fix lint
This commit is contained in:
@@ -31,7 +31,7 @@ class Config:
|
|||||||
self.username_min_length = int(params["username_min_length"])
|
self.username_min_length = int(params["username_min_length"])
|
||||||
self.username_max_length = int(params["username_max_length"])
|
self.username_max_length = int(params["username_max_length"])
|
||||||
self.password_min_length = int(params["password_min_length"])
|
self.password_min_length = int(params["password_min_length"])
|
||||||
self.invite_token = params["invite_token"]
|
self.invite_token = params.get("invite_token", "")
|
||||||
self.passthrough_senders = params["passthrough_senders"].split()
|
self.passthrough_senders = params["passthrough_senders"].split()
|
||||||
self.passthrough_recipients = params["passthrough_recipients"].split()
|
self.passthrough_recipients = params["passthrough_recipients"].split()
|
||||||
self.www_folder = params.get("www_folder", "")
|
self.www_folder = params.get("www_folder", "")
|
||||||
|
|||||||
@@ -25,10 +25,15 @@ def is_allowed_to_create(config: Config, user, cleartext_password) -> bool:
|
|||||||
"""Return True if user and password are admissable."""
|
"""Return True if user and password are admissable."""
|
||||||
if os.path.exists(NOCREATE_FILE):
|
if os.path.exists(NOCREATE_FILE):
|
||||||
if config.invite_token and config.invite_token not in cleartext_password:
|
if config.invite_token and config.invite_token not in cleartext_password:
|
||||||
logging.warning(f"blocked account creation because {NOCREATE_FILE!r} exists.")
|
logging.warning(
|
||||||
|
f"blocked account creation because {NOCREATE_FILE!r} exists."
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if len(cleartext_password.replace(config.invite_token, "")) < config.password_min_length:
|
if (
|
||||||
|
len(cleartext_password.replace(config.invite_token, ""))
|
||||||
|
< config.password_min_length
|
||||||
|
):
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Password needs to be at least %s characters long",
|
"Password needs to be at least %s characters long",
|
||||||
config.password_min_length,
|
config.password_min_length,
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ def create_newemail_dict(config: Config):
|
|||||||
secrets.choice(ALPHANUMERIC_PUNCT)
|
secrets.choice(ALPHANUMERIC_PUNCT)
|
||||||
for _ in range(config.password_min_length + 3)
|
for _ in range(config.password_min_length + 3)
|
||||||
)
|
)
|
||||||
redirect_uri = os.getenv("REQUEST_URI")
|
redirect_uri = os.getenv("REQUEST_URI", "/new")
|
||||||
invite_token = redirect_uri[5:] if redirect_uri != "/new" else ""
|
invite_token = "" if redirect_uri == "/new" else redirect_uri[5:]
|
||||||
return dict(email=f"{user}@{config.mail_domain}", password=f"{invite_token}{password}")
|
return dict(
|
||||||
|
email=f"{user}@{config.mail_domain}", password=f"{invite_token}{password}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def print_new_account():
|
def print_new_account():
|
||||||
|
|||||||
Reference in New Issue
Block a user