mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-18 20:59:42 +02:00
17 lines
436 B
TypeScript
17 lines
436 B
TypeScript
|
import { NextFunction, Request, Response } from 'express';
|
||
|
|
||
|
/**
|
||
|
* Middleware for checking locals.isAuthorized property, which allows to edit/create pages
|
||
|
*
|
||
|
* @param req - request object
|
||
|
* @param res - response object
|
||
|
* @param next - next function
|
||
|
*/
|
||
|
export default function allowEdit(req: Request, res: Response, next: NextFunction): void {
|
||
|
if (res.locals.isAuthorized) {
|
||
|
next();
|
||
|
} else {
|
||
|
res.redirect('/auth');
|
||
|
}
|
||
|
}
|