Development
This commit is contained in:
parent
44261e5b5c
commit
8a8e947fcf
9 changed files with 289 additions and 33 deletions
|
|
@ -327,11 +327,6 @@ def setup_docker_compose(reuse_config=False):
|
|||
print(" Dashboard container started.")
|
||||
return
|
||||
|
||||
print()
|
||||
print(" SMTP is used to send email verification codes for new accounts.")
|
||||
print(" (Gmail users: use an App Password, not your account password.)")
|
||||
print()
|
||||
|
||||
manager_email = prompt_str("Initial manager account email")
|
||||
while not manager_email or "@" not in manager_email:
|
||||
print(" Please enter a valid email address.")
|
||||
|
|
@ -345,23 +340,55 @@ def setup_docker_compose(reuse_config=False):
|
|||
credentials_key = _sec.token_urlsafe(48)
|
||||
print(f" Generated key: {credentials_key}")
|
||||
|
||||
smtp_host = prompt_str("SMTP host", default="smtp.gmail.com")
|
||||
smtp_port = prompt_str("SMTP port", default="587")
|
||||
smtp_user = prompt_str("SMTP username (email)")
|
||||
smtp_password = prompt_str("SMTP password", secret=True)
|
||||
smtp_from = prompt_str("SMTP From address", default=smtp_user)
|
||||
print()
|
||||
multi_user = prompt_yn(
|
||||
f"Enable multi-user access? (requires SMTP to send account verification emails)",
|
||||
default="n"
|
||||
)
|
||||
|
||||
app_config = {
|
||||
"initial_manager_email": manager_email,
|
||||
"credentials_key": credentials_key,
|
||||
"smtp": {
|
||||
"host": smtp_host,
|
||||
"port": int(smtp_port),
|
||||
"user": smtp_user,
|
||||
"password": smtp_password,
|
||||
"from": smtp_from,
|
||||
},
|
||||
}
|
||||
if multi_user:
|
||||
print()
|
||||
print(" (Gmail users: use an App Password, not your account password.)")
|
||||
print()
|
||||
smtp_host = prompt_str("SMTP host", default="smtp.gmail.com")
|
||||
smtp_port = prompt_str("SMTP port", default="587")
|
||||
smtp_user = prompt_str("SMTP username (email)")
|
||||
smtp_password = prompt_str("SMTP password", secret=True)
|
||||
smtp_from = prompt_str("SMTP From address", default=smtp_user)
|
||||
app_config = {
|
||||
"initial_manager_email": manager_email,
|
||||
"credentials_key": credentials_key,
|
||||
"smtp": {
|
||||
"host": smtp_host,
|
||||
"port": int(smtp_port),
|
||||
"user": smtp_user,
|
||||
"password": smtp_password,
|
||||
"from": smtp_from,
|
||||
},
|
||||
}
|
||||
else:
|
||||
print()
|
||||
print(f" Single-user mode: only {manager_email} can log in.")
|
||||
print(f" Password must be at least 8 characters.")
|
||||
print()
|
||||
while True:
|
||||
import getpass as _gp
|
||||
pw = _gp.getpass(f" Password for {manager_email}: ")
|
||||
pw2 = _gp.getpass(f" Confirm password: ")
|
||||
if pw != pw2:
|
||||
print(" Passwords do not match. Try again.")
|
||||
continue
|
||||
if len(pw) < 8:
|
||||
print(" Password must be at least 8 characters.")
|
||||
continue
|
||||
break
|
||||
import bcrypt as _bcrypt
|
||||
pw_hash = _bcrypt.hashpw(pw.encode('utf-8'), _bcrypt.gensalt()).decode('utf-8')
|
||||
app_config = {
|
||||
"initial_manager_email": manager_email,
|
||||
"credentials_key": credentials_key,
|
||||
"initial_manager_password": pw_hash,
|
||||
}
|
||||
|
||||
APP_CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
APP_CONFIG_FILE.write_text(json.dumps(app_config, indent=2) + "\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue