Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const router = Router();
- const adminbroRouter = AdminBroExpress.buildAuthenticatedRouter(
- adminBro,
- {
- authenticate: async (email, password) => {
- try {
- const account = await AuthService.getByEmail(email);
- if (!account) {
- return false;
- }
- const { password: accountPassword } =
- await AuthService.getPasswordByEmail(email);
- if (!(await isHashEqual(accountPassword, password))) {
- return false;
- }
- if (!AuthService.isAdmin(account as any)) {
- return false;
- }
- return account;
- } catch (error) {
- return false;
- }
- },
- cookiePassword: ADMINJS_COOKIE_PASSWORD,
- cookieName: ADMINJS_COOKIE_NAME,
- maxRetries: {
- count: ADMINJS_MAX_RETRIES_COUNT,
- duration: ADMINJS_MAX_RETRIES_DURATION,
- },
- },
- router,
- sessionOptions,
- );
- router.use((req, res, next) => {
- // @ts-ignore
- console.log(req.path, req.adminUser);
- return next();
- });
Advertisement
Add Comment
Please, Sign In to add comment