Brendan Abolivier 4 سال پیش
والد
کامیت
c44f41dd11
2فایلهای تغییر یافته به همراه6 افزوده شده و 13 حذف شده
  1. 0 3
      sydent/hs_federation/verifier.py
  2. 6 10
      sydent/http/servlets/threepidunbindservlet.py

+ 0 - 3
sydent/hs_federation/verifier.py

@@ -19,9 +19,6 @@ import logging
 import time
 
 from twisted.internet import defer
-from twisted.names.error import DNSNameError
-import twisted.names.client
-import twisted.names.dns
 from unpaddedbase64 import decode_base64
 import signedjson.sign
 import signedjson.key

+ 6 - 10
sydent/http/servlets/threepidunbindservlet.py

@@ -21,6 +21,7 @@ import logging
 
 from sydent.hs_federation.verifier import NoAuthenticationError
 from signedjson.sign import SignatureVerifyException
+
 from sydent.http.servlets import dict_to_json_bytes
 from sydent.db.valsession import ThreePidValSessionStore
 from sydent.util.stringutils import is_valid_client_secret
@@ -102,19 +103,14 @@ class ThreePidUnbindServlet(Resource):
 
                 valSessionStore = ThreePidValSessionStore(self.sydent)
 
-                noMatchError = {'errcode': 'M_NO_VALID_SESSION',
-                                'error': "No valid session was found matching that sid and client secret"}
-
                 try:
                     s = valSessionStore.getValidatedSession(sid, client_secret)
-                except IncorrectClientSecretException:
+                except (IncorrectClientSecretException, InvalidSessionIdException):
                     request.setResponseCode(401)
-                    request.write(dict_to_json_bytes(noMatchError))
-                    request.finish()
-                    return
-                except InvalidSessionIdException:
-                    request.setResponseCode(401)
-                    request.write(dict_to_json_bytes(noMatchError))
+                    request.write(dict_to_json_bytes({
+                        'errcode': 'M_NO_VALID_SESSION',
+                        'error': "No valid session was found matching that sid and client secret"
+                    }))
                     request.finish()
                     return
                 except SessionNotValidatedException: