Allow to change host for password recovery URL

Closes #426
This commit is contained in:
forsola
2025-05-19 14:32:33 +02:00
committed by GitHub
parent 1c39769626
commit e8e4042740
2 changed files with 5 additions and 2 deletions

View File

@@ -299,7 +299,9 @@ To enable support for multiple users perform the steps below:
* TCP ports 80, 443, 3025 and UDP port 3024 will need to be open on the PC running zoffline if it's running remotely.
* Start Zwift and create an account.
* This account will only exist on your zoffline server and has no relation with your actual Zwift account.
* To enable the password reset feature: create a ``gmail_credentials.txt`` file in the ``storage`` directory containing the login credentials of a Gmail account. You need to access https://security.google.com/settings/security/apppasswords and create an app password to allow the login from the server.
* To enable the password reset feature: create a ``gmail_credentials.txt`` file in the ``storage`` directory containing the login credentials of a Gmail account.
* You need to access https://security.google.com/settings/security/apppasswords and create an app password to allow the login from the server.
* Optionally, the third line can contain the host for the recovery URL (server IP will be used by default).
</details>

View File

@@ -680,13 +680,14 @@ def send_mail(username, token):
with open('%s/gmail_credentials.txt' % STORAGE_DIR) as f:
sender_email = f.readline().rstrip('\r\n')
password = f.readline().rstrip('\r\n')
host = f.readline().rstrip('\r\n')
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=ssl.create_default_context()) as server:
server.login(sender_email, password)
message = MIMEMultipart()
message['From'] = sender_email
message['To'] = username
message['Subject'] = "Password reset"
content = "https://%s/login/?token=%s" % (server_ip, token)
content = "https://%s/login/?token=%s" % (host if host else server_ip, token)
message.attach(MIMEText(content, 'plain'))
server.sendmail(sender_email, username, message.as_string())
server.close()