validate cookie on login

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-06 08:55:02 +08:00
parent 9acb32aaeb
commit 78b3df4019

View File

@@ -236,6 +236,20 @@ class LoginPageController extends GetxController
} }
} }
static String validateCookie(String cookie) {
return cookie
.split(';')
.where((e) {
try {
Cookie.fromSetCookieValue(e.trim());
} catch (_) {
return false;
}
return true;
})
.join(';');
}
// cookie登录 // cookie登录
Future<void> loginByCookie() async { Future<void> loginByCookie() async {
if (cookieTextController.text.isEmpty) { if (cookieTextController.text.isEmpty) {
@@ -247,7 +261,7 @@ class LoginPageController extends GetxController
"/x/member/web/account", "/x/member/web/account",
options: Options( options: Options(
headers: { headers: {
"cookie": cookieTextController.text, "cookie": validateCookie(cookieTextController.text),
}, },
extra: {'account': AnonymousAccount()}, extra: {'account': AnonymousAccount()},
), ),