feat: support guest session (#919)
This commit is contained in:
parent
24cb2ce19b
commit
9279135355
34 changed files with 741 additions and 288 deletions
|
|
@ -9,6 +9,7 @@ import { AuthForm } from '@/components/auth-form';
|
|||
import { SubmitButton } from '@/components/submit-button';
|
||||
|
||||
import { login, type LoginActionState } from '../actions';
|
||||
import { useSession } from 'next-auth/react';
|
||||
|
||||
export default function Page() {
|
||||
const router = useRouter();
|
||||
|
|
@ -23,6 +24,8 @@ export default function Page() {
|
|||
},
|
||||
);
|
||||
|
||||
const { update: updateSession } = useSession();
|
||||
|
||||
useEffect(() => {
|
||||
if (state.status === 'failed') {
|
||||
toast({
|
||||
|
|
@ -36,6 +39,7 @@ export default function Page() {
|
|||
});
|
||||
} else if (state.status === 'success') {
|
||||
setIsSuccessful(true);
|
||||
updateSession();
|
||||
router.refresh();
|
||||
}
|
||||
}, [state.status]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue