From ff865942829d05a40649edbdce6c2601e4cadf58 Mon Sep 17 00:00:00 2001 From: taoky Date: Thu, 16 Jan 2025 02:41:59 +0800 Subject: [PATCH] Fix CAS and deprecated element check --- frontend/auth_providers/sustech.py | 2 +- frontend/auth_providers/ustc.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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