From 3ba0e3ed6b94a401a84d61fbef556f86ea90fd9c Mon Sep 17 00:00:00 2001 From: wood chen Date: Sun, 9 Feb 2025 19:12:53 +0800 Subject: [PATCH] refactor: Migrate sign-in method to NextAuth direct sign-in --- src/components/auth/user-authorize.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/auth/user-authorize.tsx b/src/components/auth/user-authorize.tsx index 9fdbfbf..6d70a1d 100644 --- a/src/components/auth/user-authorize.tsx +++ b/src/components/auth/user-authorize.tsx @@ -2,18 +2,12 @@ import { useCallback, useEffect, useState } from "react"; import { useRouter } from "next/navigation"; -import { signIn } from "@/actions/user-authorize"; -import { useSession } from "next-auth/react"; +import { signIn as nextAuthSignIn, useSession } from "next-auth/react"; interface UserAuthorizeProps extends React.HTMLAttributes { data: Record; } -interface SignInResult { - error?: string; - ok?: boolean; -} - export function UserAuthorize({ className, data, @@ -30,7 +24,11 @@ export function UserAuthorize({ } setIsLoading(true); try { - const result = (await signIn({ ...data })) as SignInResult; + const result = await nextAuthSignIn("credentials", { + ...data, + redirect: false, + }); + if (result?.error) { setError(result.error); } else {