fix(auth): migrate from next-auth to better-auth (#1453)
This commit is contained in:
parent
453f5bb3e6
commit
b4f595a68c
40 changed files with 668 additions and 390 deletions
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useActionState, useEffect, useState } from "react";
|
||||
import { AuthForm } from "@/components/auth-form";
|
||||
import { SubmitButton } from "@/components/submit-button";
|
||||
import { toast } from "@/components/toast";
|
||||
import { useSession } from "@/lib/client";
|
||||
import { type RegisterActionState, register } from "../actions";
|
||||
|
||||
export default function Page() {
|
||||
|
|
@ -22,9 +22,9 @@ export default function Page() {
|
|||
}
|
||||
);
|
||||
|
||||
const { update: updateSession } = useSession();
|
||||
const { refetch } = useSession();
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: router and updateSession are stable refs
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: router and refetch are stable refs
|
||||
useEffect(() => {
|
||||
if (state.status === "user_exists") {
|
||||
toast({ type: "error", description: "Account already exists!" });
|
||||
|
|
@ -39,7 +39,7 @@ export default function Page() {
|
|||
toast({ type: "success", description: "Account created successfully!" });
|
||||
|
||||
setIsSuccessful(true);
|
||||
updateSession();
|
||||
refetch();
|
||||
router.refresh();
|
||||
}
|
||||
}, [state.status]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue