feat: restrict app access for unverified users

This commit is contained in:
Catalin Pit
2024-01-16 14:25:05 +02:00
parent b09071ebc7
commit 4aefb80989
9 changed files with 181 additions and 5 deletions

View File

@ -1,7 +1,8 @@
'use client';
import { useRouter } from 'next/navigation';
import { zodResolver } from '@hookform/resolvers/zod';
import { signIn } from 'next-auth/react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
@ -42,6 +43,7 @@ export type SignUpFormProps = {
export const SignUpForm = ({ className }: SignUpFormProps) => {
const { toast } = useToast();
const analytics = useAnalytics();
const router = useRouter();
const form = useForm<TSignUpFormSchema>({
values: {
@ -61,10 +63,12 @@ export const SignUpForm = ({ className }: SignUpFormProps) => {
try {
await signup({ name, email, password, signature });
await signIn('credentials', {
email,
password,
callbackUrl: '/',
router.push('/signin');
toast({
title: 'Registration Successful',
description: 'You have successfully registered. Please sign in to continue.',
duration: 5000,
});
analytics.capture('App: User Sign Up', {