From 9b12bf9ca3153c57b51813a95721f4cb4f9a93ea Mon Sep 17 00:00:00 2001 From: liushuxiang <276900785@qq.com> Date: Mon, 22 May 2023 00:22:53 +0800 Subject: [PATCH] fix: Fix the issue of being unable to log in when binding the same email to both GitHub and Google. --- CHANGE_LOG.md | 7 ++- src/app/api/auth/[...nextauth]/route.ts | 4 ++ src/components/auth/form.tsx | 7 ++- src/components/navbar/index.tsx | 60 +++++++++++++++---------- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md index ec42d1f..4e28b3d 100644 --- a/CHANGE_LOG.md +++ b/CHANGE_LOG.md @@ -2,13 +2,18 @@ ## v0.4.0 -> 2023-05-16 +> 2023-05-21 + +### Fixed + +- Fix the issue of being unable to log in when binding the same email to both GitHub and Google. ### Add - Add account system - Adding login guidance for users who are not logged in - Multi-language configuration for login email sending page +- Display the language model currently in use on the conversation interface ### Changed diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 5c434eb..ec58020 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -23,10 +23,14 @@ export const authOptions: NextAuthOptions = { GithubProvider({ clientId: process.env.GITHUB_ID || "", clientSecret: process.env.GITHUB_SECRET || "", + allowDangerousEmailAccountLinking: true, }), GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID || "", clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", + httpOptions: { + timeout: 40000, + }, }), ], secret: process.env.EMAIL_SECRET, diff --git a/src/components/auth/form.tsx b/src/components/auth/form.tsx index 569512d..2cd3853 100644 --- a/src/components/auth/form.tsx +++ b/src/components/auth/form.tsx @@ -46,18 +46,19 @@ const AuthForm: React.FC = () => { toast.success(t("auth-success")); router.push(res.url); } catch (error) { + setLoading(false); console.log(error, "login failed"); toast.error(t("auth-failed")); - } finally { - setLoading(false); } }; const onGithubLogin = async () => { + setLoading(true); await signIn("github", { redirect: false, callbackUrl: "/" }); }; const onGoogleLogin = async () => { + setLoading(true); await signIn("google", { redirect: false, callbackUrl: "/" }); }; @@ -89,6 +90,7 @@ const AuthForm: React.FC = () => {