feat(front): routes secured under jwt session + small user component done

This commit is contained in:
2024-07-25 00:03:48 +02:00
parent fd81b532d0
commit 75e1fe4c65
25 changed files with 179 additions and 24 deletions

17
front/src/middleware.ts Normal file
View File

@@ -0,0 +1,17 @@
import { withAuth } from "next-auth/middleware";
import { authOptions } from "./modules/auth/configs/auth.options";
export default withAuth({
pages: authOptions.pages,
callbacks: {
authorized({ req, token }) {
if (token) return true;
const pathname = req.nextUrl.pathname;
return (
pathname.startsWith("/_next/") ||
pathname.startsWith("/favicon.ico") ||
pathname.startsWith("/assets/")
);
},
},
});