diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-05 17:29:27 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-05 17:29:27 +0000 |
commit | 0227618d3c3bea6c85a922d5605f526719573121 (patch) | |
tree | 287ba393a80363d6680d090c9b9401362ff4a4fa /synapse/handlers/register.py | |
parent | Dependency inject ApplicationServiceApi when creating ApplicationServicesHand... (diff) | |
download | synapse-0227618d3c3bea6c85a922d5605f526719573121.tar.xz |
Add m.login.application_service registration procedure.
This allows known application services to register any user ID under their own user namespace(s).
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index b6e19d498c..60821edb05 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -106,6 +106,26 @@ class RegistrationHandler(BaseHandler): defer.returnValue((user_id, token)) @defer.inlineCallbacks + def appservice_register(self, user_localpart, as_token): + user = UserID(user_localpart, self.hs.hostname) + user_id = user.to_string() + service = yield self.store.get_app_service_by_token(as_token) + if not service: + raise SynapseError(403, "Invalid application service token.") + if not service.is_interested_in_user(user_id): + raise SynapseError( + 400, "Invalid user localpart for this application service." + ) + token = self._generate_token(user_id) + yield self.store.register( + user_id=user_id, + token=token, + password_hash="" + ) + self.distributor.fire("registered_user", user) + defer.returnValue((user_id, token)) + + @defer.inlineCallbacks def check_recaptcha(self, ip, private_key, challenge, response): """Checks a recaptcha is correct.""" |