From 4c0fc8be6a40a767ce78bcc1d9eae603dafc8e0a Mon Sep 17 00:00:00 2001 From: luorijun Date: Tue, 22 Apr 2025 10:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E6=9F=A5=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/actions/auth/verify.ts | 5 +++++ src/app/(auth)/captcha/route.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/actions/auth/verify.ts b/src/actions/auth/verify.ts index a3af5fb..ab98fd7 100644 --- a/src/actions/auth/verify.ts +++ b/src/actions/auth/verify.ts @@ -37,17 +37,21 @@ export default async function verify(props: VerifyParams): Promise }) } catch (error) { + console.error('验证码验证失败:', error) throw new Error('验证码验证失败', {cause: error}) } } async function verifyCaptcha(userInput: string): Promise { + console.log("验证验证码:", userInput) + const cookieStore = await cookies() const hash = cookieStore.get('captcha_hash')?.value const salt = cookieStore.get('captcha_salt')?.value // 如果没有找到验证码cookie,验证失败 if (!hash || !salt) { + console.log('验证码cookie不存在') return false } @@ -59,6 +63,7 @@ async function verifyCaptcha(userInput: string): Promise { // 比较哈希值 const isValid = hash === userInputHash + console.log('验证码验证结果:', isValid, hash, userInputHash) // 验证后删除验证码cookie,防止重复使用 if (isValid) { diff --git a/src/app/(auth)/captcha/route.ts b/src/app/(auth)/captcha/route.ts index 5cd9a57..55ac513 100644 --- a/src/app/(auth)/captcha/route.ts +++ b/src/app/(auth)/captcha/route.ts @@ -61,6 +61,7 @@ function generateCaptchaImage(text: string) { export async function GET(request: Request) { const captchaText = generateCaptchaText() + console.log('生成验证码:', captchaText) // 生成验证码图像 const captchaImage = generateCaptchaImage(captchaText)