mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-15 03:41:36 +00:00
* Update next to canary * Update layout.tsx * Use canary * Remove serverActions flag warning * Use unstable_noStore * Add Date.now() test * Update metadataBase url * Create wrapper component for Cards * Update page.tsx * Misc * Delete unused data fetch * Add noStore to /invoices and /customers functions * Remove date.now() * Use canary * Rename component * Fix imports * Update types for useFormStatus and useFormState * Rename folder, add team members * fixed images and added login button pending state * Update dashboard/final-example/app/lib/data.ts Co-authored-by: Matt Kane <m@mk.gg> --------- Co-authored-by: Steven Tey <stevensteel97@gmail.com> Co-authored-by: Matt Kane <m@mk.gg>
25 lines
764 B
TypeScript
25 lines
764 B
TypeScript
import type { NextAuthConfig } from 'next-auth';
|
|
|
|
export const authConfig = {
|
|
pages: {
|
|
signIn: '/login',
|
|
},
|
|
providers: [
|
|
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
|
|
// while this file is also used in non-Node.js environments
|
|
],
|
|
callbacks: {
|
|
authorized({ auth, request: { nextUrl } }) {
|
|
const isLoggedIn = !!auth?.user;
|
|
const isOnDashboard = nextUrl.pathname.startsWith('/dashboard');
|
|
if (isOnDashboard) {
|
|
if (isLoggedIn) return true;
|
|
return false; // Redirect unathenticated users to login page
|
|
} else if (isLoggedIn) {
|
|
return Response.redirect(new URL('/dashboard', nextUrl));
|
|
}
|
|
return true;
|
|
},
|
|
},
|
|
} satisfies NextAuthConfig;
|