diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-02-13 15:06:14 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-02-13 15:06:14 +0000 |
commit | 0d872f5aa6a81a31a83205210414c6e6f362e226 (patch) | |
tree | 2d7c2eeab3df724753d2b2ee358551a780048e25 /synapse/rest/client/v1/register.py | |
parent | Merge pull request #72 from matrix-org/in_memory_sqlite_for_testing (diff) | |
parent | Fix tests which broke when event caching was introduced. (diff) | |
download | synapse-0d872f5aa6a81a31a83205210414c6e6f362e226.tar.xz |
Merge pull request #50 from matrix-org/application-services
Application Services
Diffstat (limited to 'synapse/rest/client/v1/register.py')
-rw-r--r-- | synapse/rest/client/v1/register.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/synapse/rest/client/v1/register.py b/synapse/rest/client/v1/register.py index d3399c446b..8d2115082b 100644 --- a/synapse/rest/client/v1/register.py +++ b/synapse/rest/client/v1/register.py @@ -110,7 +110,8 @@ class RegisterRestServlet(ClientV1RestServlet): stages = { LoginType.RECAPTCHA: self._do_recaptcha, LoginType.PASSWORD: self._do_password, - LoginType.EMAIL_IDENTITY: self._do_email_identity + LoginType.EMAIL_IDENTITY: self._do_email_identity, + LoginType.APPLICATION_SERVICE: self._do_app_service } session_info = self._get_session_info(request, session) @@ -276,6 +277,27 @@ class RegisterRestServlet(ClientV1RestServlet): self._remove_session(session) defer.returnValue(result) + @defer.inlineCallbacks + def _do_app_service(self, request, register_json, session): + if "access_token" not in request.args: + raise SynapseError(400, "Expected application service token.") + if "user" not in register_json: + raise SynapseError(400, "Expected 'user' key.") + + as_token = request.args["access_token"][0] + user_localpart = register_json["user"].encode("utf-8") + + handler = self.handlers.registration_handler + (user_id, token) = yield handler.appservice_register( + user_localpart, as_token + ) + self._remove_session(session) + defer.returnValue({ + "user_id": user_id, + "access_token": token, + "home_server": self.hs.hostname, + }) + def _parse_json(request): try: |