Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Make errors about email password resets much clearer (#5616)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anoadragon453 authored Jul 5, 2019
1 parent 1ee268d commit 0e54342
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/5616.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make runtime errors surrounding password reset emails much clearer.
19 changes: 8 additions & 11 deletions synapse/config/emailconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,17 @@ def read_config(self, config, **kwargs):
missing = []
for k in required:
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:
raise RuntimeError(
"email.password_reset_behaviour is set to 'local' "
"but required keys are missing: %s"
% (", ".join(["email." + k for k in missing]),)
"Password resets emails are configured to be sent from "
"this homeserver due to a partial 'email' block. "
"However, the following required keys are missing: %s"
% (", ".join(missing),)
)

# Templates for password reset emails
Expand Down Expand Up @@ -156,13 +160,6 @@ def read_config(self, config, **kwargs):
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:
required = [
"smtp_host",
Expand Down

0 comments on commit 0e54342

Please sign in to comment.