summary refs log tree commit diff
path: root/synapse/handlers/auth.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-14 15:22:21 +0100
committerErik Johnston <erik@matrix.org>2016-06-14 15:22:21 +0100
commit3b52bd1cf6a1adccd135fdec0904a1bdc25e308a (patch)
treecb5c93be89960d00288f7102ce645018a67bd623 /synapse/handlers/auth.py
parentIndicate if /sync was limited or not (diff)
parentMerge pull request #868 from matrix-org/erikj/invalid_id (diff)
downloadsynapse-3b52bd1cf6a1adccd135fdec0904a1bdc25e308a.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/paginate_sync
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r--synapse/handlers/auth.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py

index 68d0d78fc6..200793b5ed 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py
@@ -18,7 +18,7 @@ from twisted.internet import defer from ._base import BaseHandler from synapse.api.constants import LoginType from synapse.types import UserID -from synapse.api.errors import AuthError, LoginError, Codes +from synapse.api.errors import AuthError, LoginError, Codes, StoreError, SynapseError from synapse.util.async import run_on_reactor from twisted.web.client import PartialDownloadError @@ -529,6 +529,11 @@ class AuthHandler(BaseHandler): macaroon.add_first_party_caveat("time < %d" % (expiry,)) return macaroon.serialize() + def generate_delete_pusher_token(self, user_id): + macaroon = self._generate_base_macaroon(user_id) + macaroon.add_first_party_caveat("type = delete_pusher") + return macaroon.serialize() + def validate_short_term_login_token_and_get_user_id(self, login_token): try: macaroon = pymacaroons.Macaroon.deserialize(login_token) @@ -563,7 +568,12 @@ class AuthHandler(BaseHandler): except_access_token_ids = [requester.access_token_id] if requester else [] - yield self.store.user_set_password_hash(user_id, password_hash) + try: + yield self.store.user_set_password_hash(user_id, password_hash) + except StoreError as e: + if e.code == 404: + raise SynapseError(404, "Unknown user", Codes.NOT_FOUND) + raise e yield self.store.user_delete_access_tokens( user_id, except_access_token_ids )