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)