diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-06 17:10:04 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-06 17:10:04 +0000 |
commit | 73a680b2a87b309bf05b4afe2685aaba70201305 (patch) | |
tree | d59f7e58407f981d85b6d0849015048bba99d55c | |
parent | Pyflakes: unused variable. (diff) | |
download | synapse-73a680b2a87b309bf05b4afe2685aaba70201305.tar.xz |
Add errcodes for appservice registrations.
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/register.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 60821edb05..10ab9bc99e 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -18,7 +18,8 @@ from twisted.internet import defer from synapse.types import UserID from synapse.api.errors import ( - SynapseError, RegistrationError, InvalidCaptchaError, CodeMessageException + AuthError, Codes, SynapseError, RegistrationError, InvalidCaptchaError, + CodeMessageException ) from ._base import BaseHandler import synapse.util.stringutils as stringutils @@ -111,10 +112,11 @@ class RegistrationHandler(BaseHandler): 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.") + raise AuthError(403, "Invalid application service token.") if not service.is_interested_in_user(user_id): raise SynapseError( - 400, "Invalid user localpart for this application service." + 400, "Invalid user localpart for this application service.", + errcode=Codes.EXCLUSIVE ) token = self._generate_token(user_id) yield self.store.register( @@ -181,7 +183,8 @@ class RegistrationHandler(BaseHandler): ] if len(interested_services) > 0: raise SynapseError( - 400, "This user ID is reserved by an application service." + 400, "This user ID is reserved by an application service.", + errcode=Codes.EXCLUSIVE ) def _generate_token(self, user_id): |