diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-09-16 12:36:39 +0100 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-09-16 12:36:39 +0100 |
commit | cc83b06cd19f8fc52f86700c1663185a2b1a7cac (patch) | |
tree | 9f6d8c2dcae8057e52a3870ea2ada8be728a43b5 /synapse/handlers/login.py | |
parent | Added PasswordResetRestServlet. Hit the IS to confirm the email/user. Need to... (diff) | |
download | synapse-cc83b06cd19f8fc52f86700c1663185a2b1a7cac.tar.xz |
Added support for the HS to send emails. Use it to send password resets. Added email_smtp_server and email_from_address config args. Added emailutils.
Diffstat (limited to 'synapse/handlers/login.py')
-rw-r--r-- | synapse/handlers/login.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/handlers/login.py b/synapse/handlers/login.py index 101b9a81ad..80ffdd2726 100644 --- a/synapse/handlers/login.py +++ b/synapse/handlers/login.py @@ -18,6 +18,8 @@ from twisted.internet import defer from ._base import BaseHandler from synapse.api.errors import LoginError, Codes from synapse.http.client import PlainHttpClient +from synapse.util.emailutils import EmailException +import synapse.util.emailutils as emailutils import bcrypt import logging @@ -71,6 +73,18 @@ class LoginHandler(BaseHandler): is_valid = yield self._check_valid_association(user_id, email) logger.info("reset_password user=%s email=%s valid=%s", user_id, email, is_valid) + if is_valid: + try: + # send an email out + emailutils.send_email( + smtp_server=self.hs.config.email_smtp_server, + from_addr=self.hs.config.email_from_address, + to_addr=email, + subject="Password Reset", + body="TODO." + ) + except EmailException as e: + logger.exception(e) @defer.inlineCallbacks def _check_valid_association(self, user_id, email): |