aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/api
diff options
context:
space:
mode:
authorneobooru2019-05-19 21:13:01 +0200
committerShyam Sunder2019-07-22 20:26:09 -0400
commit80d272d60b407d058d3092c564418979529130d3 (patch)
treee204d3b1277b0ec89bf62d861409476ed5c90cb9 /server/szurubooru/api
parent8f0835f27b8469859ec3c8723b8199f106b97ca5 (diff)
server/config: Add 'domain' and 'smtp from' config entries
Fixes #193 and #256 This however requires users to manually set the domain in the config.yaml. This field currently is optional, but it would probably be better to make it required and not fall back to HTTP_ORIGIN and HTTP_REFERER, which might be inaccurate or not set (especially behind reverse proxies and the like) server/config: Leave domain empty by default Co-Authored-By: Shyam Sunder <sgsunder1@gmail.com>
Diffstat (limited to 'server/szurubooru/api')
-rw-r--r--server/szurubooru/api/password_reset_api.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/szurubooru/api/password_reset_api.py b/server/szurubooru/api/password_reset_api.py
index 887d2f0..5296d23 100644
--- a/server/szurubooru/api/password_reset_api.py
+++ b/server/szurubooru/api/password_reset_api.py
@@ -22,14 +22,18 @@ def start_password_reset(
user_name))
token = auth.generate_authentication_token(user)
- if 'HTTP_ORIGIN' in ctx.env:
+ if config.config['domain']:
+ url = config.config['domain']
+ elif 'HTTP_ORIGIN' in ctx.env:
url = ctx.env['HTTP_ORIGIN'].rstrip('/')
+ elif 'HTTP_REFERER' in ctx.env:
+ url = ctx.env['HTTP_REFERER'].rstrip('/')
else:
url = ''
url += '/password-reset/%s:%s' % (user.name, token)
mailer.send_mail(
- 'noreply@%s' % config.config['name'],
+ config.config['smtp']['from'],
user.email,
MAIL_SUBJECT.format(name=config.config['name']),
MAIL_BODY.format(name=config.config['name'], url=url))

© 2015 - 2026 Jakob L. Kreuze