's'
This commit is contained in:
@@ -66,9 +66,10 @@ async function checkVipByEmailFromPayjsapi(
|
||||
request: NextRequest,
|
||||
email: string,
|
||||
password: string,
|
||||
userId?: string
|
||||
userId?: string,
|
||||
wechatUserId?: string
|
||||
): Promise<PayjsVipEmailResult | null> {
|
||||
const inflightKey = `${email}::${userId || ""}`;
|
||||
const inflightKey = `${email}::${userId || ""}::${wechatUserId || ""}`;
|
||||
const existed = inflightEmailChecks.get(inflightKey);
|
||||
if (existed) {
|
||||
return existed;
|
||||
@@ -96,6 +97,7 @@ async function checkVipByEmailFromPayjsapi(
|
||||
email,
|
||||
password,
|
||||
...(userId ? { user_id: userId } : {}),
|
||||
...(wechatUserId ? { wechat_userid: wechatUserId } : {}),
|
||||
}),
|
||||
cache: "no-store",
|
||||
signal: AbortSignal.timeout(PAYJS_CHECK_BY_EMAIL_TIMEOUT),
|
||||
@@ -291,6 +293,9 @@ export async function POST(request: NextRequest) {
|
||||
const requestedAnonymousUserId = String(
|
||||
body?.user_id ?? body?.anonymousUserId ?? ""
|
||||
).trim();
|
||||
const wechatUserId = String(
|
||||
body?.wechat_userid ?? body?.userid ?? ""
|
||||
).trim();
|
||||
|
||||
console.log(
|
||||
"[check-by-email] request email=%s user_id=%s",
|
||||
@@ -326,7 +331,8 @@ export async function POST(request: NextRequest) {
|
||||
request,
|
||||
email,
|
||||
password,
|
||||
requestedAnonymousUserId || undefined
|
||||
requestedAnonymousUserId || undefined,
|
||||
wechatUserId || undefined
|
||||
);
|
||||
// PB 登录失败时,尝试使用 payjsapi 返回的 token/record 兜底恢复
|
||||
if (payjsResult?.vip && payjsResult.token && payjsResult.record?.id) {
|
||||
@@ -357,7 +363,8 @@ export async function POST(request: NextRequest) {
|
||||
request,
|
||||
email,
|
||||
password,
|
||||
requestedAnonymousUserId || undefined
|
||||
requestedAnonymousUserId || undefined,
|
||||
wechatUserId || undefined
|
||||
);
|
||||
}
|
||||
if (payjsResult?.vip) {
|
||||
@@ -397,7 +404,8 @@ export async function POST(request: NextRequest) {
|
||||
request,
|
||||
email,
|
||||
password,
|
||||
requestedAnonymousUserId || undefined
|
||||
requestedAnonymousUserId || undefined,
|
||||
wechatUserId || undefined
|
||||
);
|
||||
recovery = await resolveRecovery(
|
||||
adminToken,
|
||||
@@ -451,6 +459,20 @@ export async function POST(request: NextRequest) {
|
||||
anonymousUserId
|
||||
);
|
||||
|
||||
if (wechatUserId) {
|
||||
const apiUrl = resolvePayApiUrl(request);
|
||||
await fetch(`${apiUrl}/nomadvip/wechat_profile`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
user_id: anonymousUserId || authData.record.id,
|
||||
email,
|
||||
wechat_userid: wechatUserId,
|
||||
}),
|
||||
cache: "no-store",
|
||||
}).catch(() => null);
|
||||
}
|
||||
|
||||
console.log(
|
||||
"[check-by-email] success source=%s pbUserId=%s anonymousUserId=%s",
|
||||
recovery.source ?? "pocketbase",
|
||||
|
||||
Reference in New Issue
Block a user