diff options
author | Richard van der Hoff <richard@matrix.org> | 2017-12-04 15:47:27 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2017-12-05 09:40:05 +0000 |
commit | d5f9fb06b064f2249071a5109b7cf9153b1e1f24 (patch) | |
tree | 7fe3c29ecf0f54d80e53116aa18411f6771cbc15 /synapse/rest/client/v2_alpha/register.py | |
parent | Merge pull request #2721 from matrix-org/rav/get_user_by_access_token_comments (diff) | |
download | synapse-d5f9fb06b064f2249071a5109b7cf9153b1e1f24.tar.xz |
Refactor UI auth implementation
Instead of returning False when auth is incomplete, throw an exception which can be caught with a wrapper.
Diffstat (limited to 'synapse/rest/client/v2_alpha/register.py')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index 9e2f7308ce..e9d88a8895 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -27,7 +27,7 @@ from synapse.http.servlet import ( ) from synapse.util.msisdn import phone_number_to_msisdn -from ._base import client_v2_patterns +from ._base import client_v2_patterns, interactive_auth_handler import logging import hmac @@ -176,6 +176,7 @@ class RegisterRestServlet(RestServlet): self.device_handler = hs.get_device_handler() self.macaroon_gen = hs.get_macaroon_generator() + @interactive_auth_handler @defer.inlineCallbacks def on_POST(self, request): yield run_on_reactor() @@ -325,14 +326,10 @@ class RegisterRestServlet(RestServlet): [LoginType.MSISDN, LoginType.EMAIL_IDENTITY], ]) - authed, auth_result, params, session_id = yield self.auth_handler.check_auth( + auth_result, params, session_id = yield self.auth_handler.check_auth( flows, body, self.hs.get_ip_from_request(request) ) - if not authed: - defer.returnValue((401, auth_result)) - return - if registered_user_id is not None: logger.info( "Already registered user ID %r for this session", |