Files
Momento/memento-note/auth.config.ts
Sepehr Ramezani 5b7cbcbc49 docs: add complete guide, env files, fix docker-compose
- Add GUIDE.md: complete user documentation covering installation,
  Docker deployment, AI providers, MCP server, N8N integration,
  email config, admin panel, env var reference, troubleshooting
- Add mcp-server/.env.example with all MCP-specific variables
- Update .env.docker.example with all 42 environment variables
- Fix docker-compose.yml: parameterize PostgreSQL credentials,
  add missing env vars (CUSTOM_OPENAI, AI_PROVIDER_CHAT,
  ALLOW_REGISTRATION, RESEND_API_KEY)
- Track memento-note/.env.example
2026-04-20 22:57:09 +02:00

52 lines
1.5 KiB
TypeScript

import type { NextAuthConfig } from 'next-auth';
export const authConfig = {
pages: {
signIn: '/login',
newUser: '/register',
},
secret: process.env.NEXTAUTH_SECRET,
trustHost: true,
session: {
strategy: 'jwt',
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = !!auth?.user;
const isAdmin = (auth?.user as any)?.role === 'ADMIN';
const isDashboardPage = nextUrl.pathname === '/' ||
nextUrl.pathname.startsWith('/reminders') ||
nextUrl.pathname.startsWith('/archive') ||
nextUrl.pathname.startsWith('/trash') ||
nextUrl.pathname.startsWith('/settings');
const isAdminPage = nextUrl.pathname.startsWith('/admin');
if (isAdminPage) {
return isLoggedIn && isAdmin;
}
if (isDashboardPage) {
if (isLoggedIn) return true;
return false;
} else if (isLoggedIn && (nextUrl.pathname === '/login' || nextUrl.pathname === '/register')) {
return Response.redirect(new URL('/', nextUrl));
}
return true;
},
async jwt({ token, user }) {
if (user) {
token.id = user.id;
token.role = (user as any).role;
}
return token;
},
async session({ session, token }) {
if (token && session.user) {
(session.user as any).id = token.id;
(session.user as any).role = token.role;
}
return session;
},
},
providers: [],
} satisfies NextAuthConfig;