mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
refactor: Migrate sign-in method to NextAuth direct sign-in
This commit is contained in:
parent
fc347747c4
commit
3ba0e3ed6b
@ -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<HTMLDivElement> {
|
||||
data: Record<string, any>;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user