fix(auth): correct login detection + return to origin after login
- isUserLoggedIn() checked the access_token cookie, which is never set (access_token lives in memory / tokenStore; only userInfo + uuid are cookies). It therefore always returned false — the claim modal (and comment auth checks) kept showing the login prompt even when logged in. Now reads the userInfo cookie. - Claim modal login link carries ?redirect=<current path>; after OTP login SendReq returns to that path (guarded to internal "/..." only, blocks protocol-relative //) instead of always going to "/". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,7 +86,12 @@ function SendReq({
|
||||
if (setStep) {
|
||||
setStep(3);
|
||||
} else {
|
||||
window.location.href = "/";
|
||||
// بازگشت به صفحهٔ مبدأ اگر ?redirect= داده شده (فقط مسیر داخلی امن)
|
||||
const redirect = new URLSearchParams(window.location.search).get("redirect");
|
||||
window.location.href =
|
||||
redirect && redirect.startsWith("/") && !redirect.startsWith("//")
|
||||
? redirect
|
||||
: "/";
|
||||
}
|
||||
} else {
|
||||
setIsError(true);
|
||||
|
||||
Reference in New Issue
Block a user