summary refs log tree commit diff
path: root/synapse/rest/client/v1/logout.py
diff options
context:
space:
mode:
authorAaron Raimist <aaron@raim.ist>2019-05-27 00:13:48 -0500
committerAaron Raimist <aaron@raim.ist>2019-05-27 00:13:56 -0500
commit119c9c10b026b65affab5d5bcb6ae1d3d7e7229c (patch)
treeb86a1ff415c2db99ce18199d04741859d5df54fc /synapse/rest/client/v1/logout.py
parentAdd changelog (diff)
downloadsynapse-119c9c10b026b65affab5d5bcb6ae1d3d7e7229c.tar.xz
Get rid of try except
Signed-off-by: Aaron Raimist <aaron@raim.ist>
Diffstat (limited to 'synapse/rest/client/v1/logout.py')
-rw-r--r--synapse/rest/client/v1/logout.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/synapse/rest/client/v1/logout.py b/synapse/rest/client/v1/logout.py
index 317f52cb56..2cf373e83c 100644
--- a/synapse/rest/client/v1/logout.py
+++ b/synapse/rest/client/v1/logout.py
@@ -38,23 +38,16 @@ class LogoutRestServlet(ClientV1RestServlet):
 
     @defer.inlineCallbacks
     def on_POST(self, request):
-        try:
-            requester = yield self.auth.get_user_by_req(request)
-        except AuthError as e:
-            # this implies the access token has already been deleted.
-            defer.returnValue((e.code, {
-                "errcode": e.errcode,
-                "error": e.msg
-            }))
+        requester = yield self.auth.get_user_by_req(request)
+
+        if requester.device_id is None:
+            # the acccess token wasn't associated with a device.
+            # 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:
-            if requester.device_id is None:
-                # the acccess token wasn't associated with a device.
-                # 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)
+            yield self._device_handler.delete_device(
+                requester.user.to_string(), requester.device_id)
 
         defer.returnValue((200, {}))