Preview: protected-routes.handler.ts
Size: 490 B
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/express/src/authentication/protected-routes.handler.ts
import AdminJS from "adminjs";
import { Router, RequestHandler } from "express";
export const withProtectedRoutesHandler = (
router: Router,
admin: AdminJS
): void => {
const { loginPath } = admin.options;
const authorizedRoutesMiddleware: RequestHandler = (
request,
response,
next
) => {
if (!request.session || !request.session.adminUser) {
return response.redirect(loginPath);
}
return next();
};
router.use(authorizedRoutesMiddleware);
};
Directory Contents
Dirs: 0 × Files: 4