Skip to content

Commit

Permalink
Fix CAS and deprecated element check
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Jan 15, 2025
1 parent 5fce378 commit ff86594
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/auth_providers/sustech.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions frontend/auth_providers/ustc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ff86594

Please sign in to comment.