fix: preserve skill deep link through login flow
This commit is contained in:
1 parent
1d31de4796
commit
bbe241348e
2 files changed
+27
-2
No files matched your search
@@ -1376,6 +1376,11 @@
|
|||||||
window.location.href = dest;
|
window.location.href = dest;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem("post_login_redirect", dest);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("sessionStorage unavailable", error);
|
||||||
|
}
|
||||||
const params = new URLSearchParams({ v: "20261107", redirect: dest });
|
const params = new URLSearchParams({ v: "20261107", redirect: dest });
|
||||||
window.location.href = "/login/?" + params.toString();
|
window.location.href = "/login/?" + params.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-2
@@ -71,10 +71,30 @@ function renderQrCode(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 只接受站内绝对路径,避免 ?redirect= 被当作开放重定向
|
// 只接受站内绝对路径,避免 ?redirect= 被当作开放重定向
|
||||||
|
function consumePostLoginRedirect(): string {
|
||||||
|
try {
|
||||||
|
const stored = sessionStorage.getItem('post_login_redirect')
|
||||||
|
if (stored && stored.startsWith('/') && !stored.startsWith('//')) {
|
||||||
|
sessionStorage.removeItem('post_login_redirect')
|
||||||
|
return stored
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('读取登录后跳转地址失败', error)
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
function redirectTarget(): string {
|
function redirectTarget(): string {
|
||||||
const redirect = new URLSearchParams(window.location.search).get('redirect')
|
const redirect = new URLSearchParams(window.location.search).get('redirect')
|
||||||
if (redirect && redirect.startsWith('/') && !redirect.startsWith('//')) return redirect
|
if (redirect && redirect.startsWith('/') && !redirect.startsWith('//')) {
|
||||||
return '/generate'
|
try {
|
||||||
|
sessionStorage.removeItem('post_login_redirect')
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('清理登录后跳转地址失败', error)
|
||||||
|
}
|
||||||
|
return redirect
|
||||||
|
}
|
||||||
|
return consumePostLoginRedirect() || '/generate'
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cacheTeam(token: string): Promise<void> {
|
async function cacheTeam(token: string): Promise<void> {
|
||||||
|
|||||||
Reference in new issue
Block a user