chore: add .gitignore, clean tracked junk files

This commit is contained in:
2026-05-29 08:33:35 +08:00
parent 2d5c5d4c0d
commit 1ccb116f80
53 changed files with 189 additions and 2445 deletions
+28
View File
@@ -108,6 +108,34 @@ class CasdoorAuth:
pass # 如果无法记录日志,忽略错误
return None
def get_account_info(self, access_token):
"""
使用访问令牌获取完整账户信息(包含标签等字段)
"""
account_url = f"{self.endpoint}/api/get-account"
headers = {
'Authorization': f'Bearer {access_token}'
}
try:
response = requests.get(account_url, headers=headers)
response.raise_for_status()
result = response.json()
# Casdoor 通常返回 {"status": "ok", "data": {...}}
if isinstance(result, dict):
if result.get('status') == 'ok' and isinstance(result.get('data'), dict):
return result['data']
if 'data' in result and isinstance(result.get('data'), dict):
return result['data']
return result if isinstance(result, dict) else None
except requests.exceptions.RequestException as e:
try:
current_app.logger.error(f"获取 Casdoor 账户信息失败: {str(e)}")
except:
pass
return None
def verify_state(self, state):
"""
验证 state 参数,防止 CSRF 攻击