mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-19 14:31:56 +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 { useCallback, useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { signIn } from "@/actions/user-authorize";
|
import { signIn as nextAuthSignIn, useSession } from "next-auth/react";
|
||||||
import { useSession } from "next-auth/react";
|
|
||||||
|
|
||||||
interface UserAuthorizeProps extends React.HTMLAttributes<HTMLDivElement> {
|
interface UserAuthorizeProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
data: Record<string, any>;
|
data: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SignInResult {
|
|
||||||
error?: string;
|
|
||||||
ok?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function UserAuthorize({
|
export function UserAuthorize({
|
||||||
className,
|
className,
|
||||||
data,
|
data,
|
||||||
@ -30,7 +24,11 @@ export function UserAuthorize({
|
|||||||
}
|
}
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = (await signIn({ ...data })) as SignInResult;
|
const result = await nextAuthSignIn("credentials", {
|
||||||
|
...data,
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
setError(result.error);
|
setError(result.error);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user