diff --git a/frontend/auth_providers/sustech.py b/frontend/auth_providers/sustech.py index e6e467d..ea20eb4 100644 --- a/frontend/auth_providers/sustech.py +++ b/frontend/auth_providers/sustech.py @@ -28,7 +28,7 @@ def login_attrs(self) -> dict[str, Any]: def check_ticket(self) -> Optional[ElementTree.Element]: tree = super().check_ticket() - if not tree: + if tree is None: return None self.identity = tree.find(self.YALE_CAS_URL + 'user').text.strip() self.email = tree.find(self.YALE_CAS_URL + 'attributes').find(self.YALE_CAS_URL + 'mail').text.strip() diff --git a/frontend/auth_providers/ustc.py b/frontend/auth_providers/ustc.py index 5dd9779..2cd79df 100644 --- a/frontend/auth_providers/ustc.py +++ b/frontend/auth_providers/ustc.py @@ -26,12 +26,13 @@ def login_attrs(self) -> dict[str, Any]: def check_ticket(self) -> Optional[ElementTree.Element]: tree = super().check_ticket() - if not tree: + if tree is None: return None - self.identity = tree.find(self.YALE_CAS_URL + 'attributes').find(self.YALE_CAS_URL + 'gid').text.strip() - if not self.identity: + attributes = tree.find(self.YALE_CAS_URL + 'attributes') + if attributes is None: # compatibility with old ustc cas - self.identity = tree.find('attributes').find(self.YALE_CAS_URL + 'gid').text.strip() + attributes = tree.find('attributes') + self.identity = attributes.find(self.YALE_CAS_URL + 'gid').text.strip() self.sno = tree.find(self.YALE_CAS_URL + 'user').text.strip() return tree