PHP 8.2.30
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

Name Size Perms Modified Actions
4.25 KB lrw-r--r-- 2026-02-28 00:29:04
Edit Download
935 B lrw-r--r-- 2026-02-28 00:29:06
Edit Download
490 B lrw-r--r-- 2026-02-28 00:29:10
Edit Download
1.53 KB lrw-r--r-- 2026-02-28 00:29:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).