From 9188f20860a2b2ba2c7a39adc8c9312eca4722ef Mon Sep 17 00:00:00 2001 From: sijinhui Date: Thu, 18 Apr 2024 17:58:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=92=E7=BB=9D=E6=96=B0=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/auth.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/auth.ts b/lib/auth.ts index 275790032..e58227197 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -94,9 +94,9 @@ export const authOptions: NextAuthOptions = { let existingUser = await existUser(user); // await insertUser(user) if (!existingUser) { // 如果不存在,则报错 - // throw new Error("用户查询失败") + throw new Error("用户名或密码不正确") // 如果不存在,则创建 - existingUser = await insertUser(user); + // existingUser = await insertUser(user); } // 有密码就校验密码,没有就直接返回用户 (password || existingUser.password) && validatePassword(password, existingUser.password); @@ -104,7 +104,7 @@ export const authOptions: NextAuthOptions = { } else { // If you return null then an error will be displayed advising the user to check their details. // return null - throw new Error("用户名校验失败") + throw new Error("用户名或密码不正确") // You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter } } @@ -153,11 +153,11 @@ export const authOptions: NextAuthOptions = { return session; }, // 过滤不存在的用户,目前没用 - // async signIn({ user, account, profile, email, credentials }) { - // const existingUser = await existUser(user as User); - // console.log('---', user, 'account', account, 'email', email, 'exist', existingUser) - // return !!existingUser; - // } + async signIn({ user, account, profile, email, credentials }) { + const existingUser = await existUser(user as User); + console.log('---', user, 'account', account, 'email', email, 'exist', existingUser) + return !!existingUser; + } }, };