chore: add .gitignore, clean tracked junk files
This commit is contained in:
@@ -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 攻击
|
||||
|
||||
Reference in New Issue
Block a user