diff options
author | David Baker <dave@matrix.org> | 2015-08-04 14:37:09 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-08-04 14:37:09 +0100 |
commit | c77048e12f032842cebbb0f1a0639bb62db88418 (patch) | |
tree | 9f9f29aa34f422d081ccef3fa177dd4362a45adb /synapse/handlers/identity.py | |
parent | Don't try & check the username if we don't have one (which we won't if it's b... (diff) | |
download | synapse-c77048e12f032842cebbb0f1a0639bb62db88418.tar.xz |
Add endpoint that proxies ID server request token and errors if the given email is in use on this Home Server.
Diffstat (limited to 'synapse/handlers/identity.py')
-rw-r--r-- | synapse/handlers/identity.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py index c1095708a0..2a99921d5f 100644 --- a/synapse/handlers/identity.py +++ b/synapse/handlers/identity.py @@ -117,3 +117,28 @@ class IdentityHandler(BaseHandler): except CodeMessageException as e: data = json.loads(e.msg) defer.returnValue(data) + + @defer.inlineCallbacks + def requestEmailToken(self, id_server, email, client_secret, send_attempt, **kwargs): + yield run_on_reactor() + http_client = SimpleHttpClient(self.hs) + + params = { + 'email': email, + 'client_secret': client_secret, + 'send_attempt': send_attempt, + } + params.update(kwargs) + + try: + data = yield http_client.post_urlencoded_get_json( + "https://%s%s" % ( + id_server, + "/_matrix/identity/api/v1/validate/email/requestToken" + ), + params + ) + defer.returnValue(data) + except CodeMessageException as e: + logger.info("Proxied requestToken failed: %r", e) + raise e |