forked from MirrorHub/synapse
Make errors about email password resets much clearer (#5616)
The runtime errors that dealt with local email password resets talked about config options that users may not even have in their config file yet (if upgrading). Instead, the cryptic errors are now replaced with hopefully much more helpful ones.
This commit is contained in:
parent
1ee268d33d
commit
0e5434264f
2 changed files with 9 additions and 11 deletions
1
changelog.d/5616.misc
Normal file
1
changelog.d/5616.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Make runtime errors surrounding password reset emails much clearer.
|
|
@ -112,13 +112,17 @@ class EmailConfig(Config):
|
||||||
missing = []
|
missing = []
|
||||||
for k in required:
|
for k in required:
|
||||||
if k not in email_config:
|
if k not in email_config:
|
||||||
missing.append(k)
|
missing.append("email." + k)
|
||||||
|
|
||||||
|
if config.get("public_baseurl") is None:
|
||||||
|
missing.append("public_base_url")
|
||||||
|
|
||||||
if len(missing) > 0:
|
if len(missing) > 0:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"email.password_reset_behaviour is set to 'local' "
|
"Password resets emails are configured to be sent from "
|
||||||
"but required keys are missing: %s"
|
"this homeserver due to a partial 'email' block. "
|
||||||
% (", ".join(["email." + k for k in missing]),)
|
"However, the following required keys are missing: %s"
|
||||||
|
% (", ".join(missing),)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Templates for password reset emails
|
# Templates for password reset emails
|
||||||
|
@ -156,13 +160,6 @@ class EmailConfig(Config):
|
||||||
filepath, "email.password_reset_template_success_html"
|
filepath, "email.password_reset_template_success_html"
|
||||||
)
|
)
|
||||||
|
|
||||||
if config.get("public_baseurl") is None:
|
|
||||||
raise RuntimeError(
|
|
||||||
"email.password_reset_behaviour is set to 'local' but no "
|
|
||||||
"public_baseurl is set. This is necessary to generate password "
|
|
||||||
"reset links"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.email_enable_notifs:
|
if self.email_enable_notifs:
|
||||||
required = [
|
required = [
|
||||||
"smtp_host",
|
"smtp_host",
|
||||||
|
|
Loading…
Reference in a new issue