fix: support Website User login by validating session cookie instead of message text

This commit is contained in:
jingrow 2025-11-18 23:18:17 +08:00
parent 7ff17ffee3
commit 76255f6757
2 changed files with 5 additions and 4 deletions

View File

@ -24,7 +24,7 @@ export const useAuthStore = defineStore('auth', () => {
try {
const response = await loginApi(username, password)
if (response.message === 'Logged In' && response.user) {
if (response.user) {
user.value = response.user
isAuthenticated.value = true

View File

@ -124,9 +124,10 @@ def login(username: str, password: str) -> dict:
response = session.post(url, headers=headers, data=data, timeout=30)
if response.status_code == 200:
session_cookie = _extract_session_cookie_from_response(response, session)
result = response.json()
if result.get("message") == "Logged In":
session_cookie = _extract_session_cookie_from_response(response, session)
if session_cookie:
return {
"success": True,
"message": result.get("message", "Logged In"),
@ -135,7 +136,7 @@ def login(username: str, password: str) -> dict:
else:
return {
"success": False,
"message": result.get("message", "登录失败")
"message": result.get("message", "登录失败:未获取到会话凭证")
}
else:
error_msg = f"登录请求失败 (HTTP {response.status_code})"