's'
This commit is contained in:
@@ -15,6 +15,8 @@ const ANONYMOUS_USER_COOKIE = "nomadvip_anon_uid";
|
||||
const ANONYMOUS_USER_COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
||||
const PAY_ORDER_COOKIE = "nomadvip_pay_order";
|
||||
const PAY_ORDER_MAX_AGE = 60 * 15;
|
||||
const EMAIL_VERIFY_TS_KEY = "emailVerifyAt";
|
||||
const EMAIL_VERIFY_COOLDOWN_MS = 60 * 1000;
|
||||
|
||||
function getStorage(key: string): string | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
@@ -174,6 +176,7 @@ export default function Home() {
|
||||
savePaidType("vip");
|
||||
setUserEmail(normalizedEmail);
|
||||
saveUserName(normalizedEmail);
|
||||
setStorage(EMAIL_VERIFY_TS_KEY, String(Date.now()));
|
||||
return true;
|
||||
},
|
||||
[savePaidType, saveUserName]
|
||||
@@ -485,7 +488,10 @@ export default function Home() {
|
||||
// 校验逻辑:有本地存储(登录资料+VIP)时优先使用并校验;无身份/VIP 时点击按钮直接进入支付,不校验
|
||||
const anonymousCandidate = getStoredAnonymousUserId();
|
||||
const hadStoredUserId = !!anonymousCandidate;
|
||||
if (anonymousCandidate) {
|
||||
const emailVerifiedAt = Number(getStorage(EMAIL_VERIFY_TS_KEY) || "0");
|
||||
const skipAnonymousRecover =
|
||||
!!(getStorage("emailLinked") === "1" && Date.now() - emailVerifiedAt < EMAIL_VERIFY_COOLDOWN_MS);
|
||||
if (anonymousCandidate && !skipAnonymousRecover) {
|
||||
const recovered = await tryRecoverByAnonymousUserId(anonymousCandidate);
|
||||
if (recovered) {
|
||||
setStorage("userId", anonymousCandidate);
|
||||
|
||||
Reference in New Issue
Block a user