Implemented email verification

This commit is contained in:
2024-04-12 13:52:16 +03:00
parent 78107d4ec7
commit b1ad7b5c3e
51 changed files with 604 additions and 213 deletions

View File

@@ -17,15 +17,12 @@ interface AppRouteHandlerFnContext {
params?: Record<string, string | string[]>;
}
export const middleware = (
request: NextRequest,
event: AppRouteHandlerFnContext): NextResponse | null => {
export const middleware = (request: NextRequest, event: AppRouteHandlerFnContext): NextResponse | null => {
return NextAuth(authConfig).auth((request): any => {
const { nextUrl }: { nextUrl: NextURL } = request
const isLoggedIn: boolean = !!request.auth
const isApiAuthRoute: boolean = nextUrl.pathname.startsWith(apiAuthPrefix)
const isPublicRoute: boolean = testPathnameRegex(publicRoutes,
nextUrl.pathname)
const isPublicRoute: boolean = testPathnameRegex(publicRoutes, nextUrl.pathname)
const isAuthRoute: boolean = testPathnameRegex(authRoutes, nextUrl.pathname)
if (isApiAuthRoute) {
@@ -54,7 +51,6 @@ export const middleware = (
export const config = {
matcher: [
'/((?!.+\\.[\\w]+$|_next).*)',
'/(api|static|trpc)(.*)'],
'/((?!.+\\.[\\w]+$|_next).*)', '/(api|static|trpc)(.*)'],
}