diff options
author | David Baker <dbkr@users.noreply.github.com> | 2016-03-17 14:34:08 +0000 |
---|---|---|
committer | David Baker <dbkr@users.noreply.github.com> | 2016-03-17 14:34:08 +0000 |
commit | 384ee6eafba3f6b76652e2ffb336c66a16aa849d (patch) | |
tree | 48b2efc3a703a21e66f449c37e4aaef36567b9f6 /synapse/rest | |
parent | Merge pull request #651 from matrix-org/markjh/unused_II (diff) | |
parent | remove debug logging (diff) | |
download | synapse-384ee6eafba3f6b76652e2ffb336c66a16aa849d.tar.xz |
Merge pull request #650 from matrix-org/dbkr/register_idempotent_with_username
Make registration idempotent, part 2
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index c440430e25..d32c06c882 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -122,10 +122,22 @@ class RegisterRestServlet(RestServlet): guest_access_token = body.get("guest_access_token", None) + session_id = self.auth_handler.get_session_id(body) + registered_user_id = None + if session_id: + # if we get a registered user id out of here, it means we previously + # registered a user for this session, so we could just return the + # user here. We carry on and go through the auth checks though, + # for paranoia. + registered_user_id = self.auth_handler.get_session_data( + session_id, "registered_user_id", None + ) + if desired_username is not None: yield self.registration_handler.check_username( desired_username, - guest_access_token=guest_access_token + guest_access_token=guest_access_token, + assigned_user_id=registered_user_id, ) if self.hs.config.enable_registration_captcha: @@ -147,10 +159,6 @@ class RegisterRestServlet(RestServlet): defer.returnValue((401, result)) return - # have we already registered a user for this session - registered_user_id = self.auth_handler.get_session_data( - session_id, "registered_user_id", None - ) if registered_user_id is not None: logger.info( "Already registered user ID %r for this session", |