/** * @module auth.config.ts * @description defines how user session is to be checked and redirects anonymous user to login page */ import type { NextAuthConfig } from 'next-auth'; export const authConfig = { pages: { signIn: '/login', }, // this will prevent users from accessing the dashboard pages unless they are logged in callbacks: { // The authorized callback is used to verify if the request is authorized to access a // page via Next.js Middleware. It is called before a request is completed, and it // receives an object with the auth and request properties. // The auth property contains the user's session, and the request property contains // the incoming request. authorized({ auth, request: { nextUrl } }) { const isLoggedIn = !!auth?.user; return(isLoggedIn); }, }, providers: [], // Add providers with an empty array for now } satisfies NextAuthConfig;