mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #5256 from aaronraimist/logout-correct-error
Show correct error when logging out and access token is missing
This commit is contained in:
commit
45f5d8f3fd
1
changelog.d/5256.bugfix
Normal file
1
changelog.d/5256.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Show the correct error when logging out and access token is missing.
|
@ -17,8 +17,6 @@ import logging
|
|||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.errors import AuthError
|
|
||||||
|
|
||||||
from .base import ClientV1RestServlet, client_path_patterns
|
from .base import ClientV1RestServlet, client_path_patterns
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -38,23 +36,16 @@ class LogoutRestServlet(ClientV1RestServlet):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_POST(self, request):
|
def on_POST(self, request):
|
||||||
try:
|
requester = yield self.auth.get_user_by_req(request)
|
||||||
requester = yield self.auth.get_user_by_req(request)
|
|
||||||
except AuthError:
|
if requester.device_id is None:
|
||||||
# this implies the access token has already been deleted.
|
# the acccess token wasn't associated with a device.
|
||||||
defer.returnValue((401, {
|
# Just delete the access token
|
||||||
"errcode": "M_UNKNOWN_TOKEN",
|
access_token = self._auth.get_access_token_from_request(request)
|
||||||
"error": "Access Token unknown or expired"
|
yield self._auth_handler.delete_access_token(access_token)
|
||||||
}))
|
|
||||||
else:
|
else:
|
||||||
if requester.device_id is None:
|
yield self._device_handler.delete_device(
|
||||||
# the acccess token wasn't associated with a device.
|
requester.user.to_string(), requester.device_id)
|
||||||
# Just delete the access token
|
|
||||||
access_token = self._auth.get_access_token_from_request(request)
|
|
||||||
yield self._auth_handler.delete_access_token(access_token)
|
|
||||||
else:
|
|
||||||
yield self._device_handler.delete_device(
|
|
||||||
requester.user.to_string(), requester.device_id)
|
|
||||||
|
|
||||||
defer.returnValue((200, {}))
|
defer.returnValue((200, {}))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user