diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-07-10 19:10:07 +0100 |
---|---|---|
committer | Amber Brown <hawkowl@atleastfornow.net> | 2019-07-11 04:10:07 +1000 |
commit | 1890cfcf82aa3e69530e97bf9ce783e390f22fbe (patch) | |
tree | 82f2bb7a134999614ad8e25d5b1f3e8ed254c70b /synapse | |
parent | Merge pull request #5658 from matrix-org/babolivier/is-json (diff) | |
download | synapse-1890cfcf82aa3e69530e97bf9ce783e390f22fbe.tar.xz |
Inline issue_access_token (#5659)
this is only used in one place, so it's clearer if we inline it and reduce the API surface. Also, fixes a buglet where we would create an access token even if we were about to block the user (we would never return the AT, so the user could never use it, but it was still created and added to the db.)
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/auth.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py index ef5585aa99..da312b188e 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py @@ -578,9 +578,11 @@ class AuthHandler(BaseHandler): StoreError if there was a problem storing the token. """ logger.info("Logging in user %s on device %s", user_id, device_id) - access_token = yield self.issue_access_token(user_id, device_id) yield self.auth.check_auth_blocking(user_id) + access_token = self.macaroon_gen.generate_access_token(user_id) + yield self.store.add_access_token_to_user(user_id, access_token, device_id) + # the device *should* have been registered before we got here; however, # it's possible we raced against a DELETE operation. The thing we # really don't want is active access_tokens without a record of the @@ -832,12 +834,6 @@ class AuthHandler(BaseHandler): defer.returnValue(user_id) @defer.inlineCallbacks - def issue_access_token(self, user_id, device_id=None): - access_token = self.macaroon_gen.generate_access_token(user_id) - yield self.store.add_access_token_to_user(user_id, access_token, device_id) - defer.returnValue(access_token) - - @defer.inlineCallbacks def validate_short_term_login_token_and_get_user_id(self, login_token): auth_api = self.hs.get_auth() user_id = None |