修复第三方登录旧响应覆盖新会话并补充跨标签回归

This commit is contained in:
cieanyau committed 2026-11-07 01:05:45 +08:00
1 parent 30415593a6
commit c3467875c6
6 files changed
+484 -25

No files matched your search

+14 -7
View File
@@ -119,6 +119,7 @@ var ve = {
H = ref(``),
U = ref(!1),
W = ref(!1),
loginAttempt = null,
G = !0;
onBeforeUnmount(() => {
G = !1;
@@ -127,6 +128,8 @@ var ve = {
async function K() {
if (!W.value && G) {
((W.value = !0), (U.value = !1), (H.value = ``));
const attempt = A.prepareLogin();
loginAttempt = attempt;
try {
if (N) {
if (!P) throw Error(`扫码会话已过期,请返回登录重新扫码`);
@@ -134,10 +137,10 @@ var ve = {
ticket: P.ticket,
token: P.token,
});
if (!G) return;
if (!G || !attempt.isCurrent()) return;
if (e.status === `Success` && isValidJwt(e.jwt)) {
(wechat_binding_t(sessionStorage),
A.loginWithJwt(e.jwt),
attempt.commit(e.jwt),
await navigateTo(F));
return;
}
@@ -147,7 +150,7 @@ var ve = {
return;
}
let t = await S.get(`/oauth/token`);
if (!G) return;
if (!G || !attempt.isCurrent()) return;
let n = oauth_n(
t,
window.location.origin,
@@ -159,7 +162,7 @@ var ve = {
).origin,
);
if (n.kind === `login`) {
(A.loginWithJwt(n.jwt), await navigateTo(`/`));
(attempt.commit(n.jwt), await navigateTo(`/`));
return;
}
if (n.kind !== `bind`)
@@ -167,6 +170,7 @@ var ve = {
U.value = !0;
} catch (e) {
G &&
attempt.isCurrent() &&
(H.value = e instanceof Error ? e.message : `验证授权会话失败`);
} finally {
G && (W.value = !1);
@@ -210,7 +214,8 @@ var ve = {
// 必须先验证授权会话并同意协议;提交验证码绑定,微信额外携带扫码 ticket/token,成功响应的 JWT 合法后才建立会话。
async function Le() {
if (!V.value && G) {
if (((H.value = ``), !U.value)) {
if (((H.value = ``), !U.value || !loginAttempt.isCurrent())) {
U.value = !1;
H.value = `请先验证授权会话;会话失效时请返回登录重新授权`;
return;
}
@@ -223,6 +228,7 @@ var ve = {
return;
}
V.value = !0;
const attempt = loginAttempt;
try {
let e = q.validationError?.();
if (e) throw Error(e);
@@ -244,14 +250,15 @@ var ve = {
: {}),
},
);
if (!G) return;
if (!G || !attempt.isCurrent()) return;
if (!isValidJwt(t?.jwt))
throw Error(`绑定会话已失效,请返回登录后重新发起第三方授权`);
(N && wechat_binding_t(sessionStorage),
A.loginWithJwt(t.jwt),
attempt.commit(t.jwt),
await navigateTo(F));
} catch (e) {
G &&
attempt.isCurrent() &&
((H.value =
e instanceof Error ? e.message : `绑定失败,请重试`),
await q.handleError?.(e));
+6 -3
View File
@@ -54,9 +54,10 @@ var w = {
async function A() {
if (k && !D.value) {
((D.value = !0), (O.value = ``));
const loginAttempt = E.prepareLogin();
try {
let t = await T.get(`/oauth/token`);
if (!k) return;
if (!k || !loginAttempt.isCurrent()) return;
let n = oauth_n(
t,
window.location.origin,
@@ -68,7 +69,7 @@ var w = {
).origin,
);
if (n.kind === `login`) {
E.loginWithJwt(n.jwt);
loginAttempt.commit(n.jwt);
try {
sessionStorage.removeItem(`console-oauth-pending`);
} catch {}
@@ -79,7 +80,9 @@ var w = {
window.location.replace(n.url);
} else throw Error(`授权会话已过期,请返回登录并重新授权`);
} catch (e) {
k && (O.value = e instanceof Error ? e.message : `恢复登录失败`);
k &&
loginAttempt.isCurrent() &&
(O.value = e instanceof Error ? e.message : `恢复登录失败`);
} finally {
k && (D.value = !1);
}