Story 6-2 — Markdown roundtrip export/import: - lib/editor/markdown-export.ts: tiptapHTMLToMarkdown, markdownToHTML, looksLikeMarkdown - lib/editor/markdown-paste-extension.ts: TipTap extension paste Markdown → blocs - note-editor-toolbar.tsx: export .md + import .md (file picker) - rich-text-editor.tsx: intégration MarkdownPasteExtension - 40 tests unitaires markdown-export.test.ts Story 6-3 — Brainstorm PPTX + Canvas: - lib/brainstorm/export-pptx.ts: génération PPTX 5 slides (pptxgenjs) - app/api/brainstorm/[sessionId]/export-pptx/route.ts: route POST protégée - brainstorm-page.tsx: bouton PPTX, auto-select session, fix emoji, fix router.replace - wave-canvas.tsx: fitTrigger recentrage, légende bas-droite Onboarding activation wizard (Story 6-1): - components/onboarding/: wizard multi-étapes, hints éditeur - app/api/onboarding/: route PATCH onboarding - prisma/migrations: champs onboarding user Locales: 15 langues mises à jour (brainstorm, markdown, onboarding keys) Sprint: 6-1 done, 6-2 review, 6-3 review Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76 lines
2.8 KiB
TypeScript
76 lines
2.8 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',
|
|
maxAge: 60 * 60 * 24 * 7,
|
|
updateAge: 60 * 60 * 12,
|
|
},
|
|
callbacks: {
|
|
authorized({ auth, request: { nextUrl } }) {
|
|
const isLoggedIn = !!auth?.user;
|
|
const isAdmin = (auth?.user as any)?.role === 'ADMIN';
|
|
const isDashboardPage = nextUrl.pathname === '/home' ||
|
|
nextUrl.pathname.startsWith('/reminders') ||
|
|
nextUrl.pathname.startsWith('/archive') ||
|
|
nextUrl.pathname.startsWith('/trash') ||
|
|
nextUrl.pathname.startsWith('/settings') ||
|
|
nextUrl.pathname.startsWith('/lab') ||
|
|
nextUrl.pathname.startsWith('/agents') ||
|
|
nextUrl.pathname.startsWith('/chat') ||
|
|
nextUrl.pathname.startsWith('/canvas') ||
|
|
nextUrl.pathname.startsWith('/notebooks') ||
|
|
nextUrl.pathname.startsWith('/note/') ||
|
|
nextUrl.pathname.startsWith('/brainstorm');
|
|
const isAdminPage = nextUrl.pathname.startsWith('/admin');
|
|
const isPublicPage = nextUrl.pathname === '/' ||
|
|
nextUrl.pathname === '/login' ||
|
|
nextUrl.pathname === '/register' ||
|
|
nextUrl.pathname === '/forgot-password' ||
|
|
nextUrl.pathname.startsWith('/reset-password');
|
|
|
|
if (isAdminPage) {
|
|
return isLoggedIn && isAdmin;
|
|
}
|
|
|
|
if (isDashboardPage) {
|
|
if (isLoggedIn) return true;
|
|
return false;
|
|
}
|
|
|
|
if (isLoggedIn && (nextUrl.pathname === '/login' || nextUrl.pathname === '/register')) {
|
|
return Response.redirect(new URL('/home', nextUrl));
|
|
}
|
|
|
|
return true;
|
|
},
|
|
async jwt({ token, user, trigger, session }) {
|
|
if (trigger === 'update' && session && 'aiSessionConsent' in session) {
|
|
token.aiSessionConsent = session.aiSessionConsent === true;
|
|
return token;
|
|
}
|
|
if (user) {
|
|
token.id = user.id;
|
|
token.role = (user as any).role;
|
|
token.aiSessionConsent = false;
|
|
}
|
|
return token;
|
|
},
|
|
async session({ session, token }) {
|
|
if (token && session.user) {
|
|
(session.user as any).id = token.id;
|
|
(session.user as any).role = token.role;
|
|
session.aiSessionConsent = token.aiSessionConsent === true;
|
|
(session.user as any).onboardingCompleted = token.onboardingCompleted === true;
|
|
}
|
|
return session;
|
|
},
|
|
},
|
|
providers: [],
|
|
} satisfies NextAuthConfig; |