refactor(middlewares): add type to function parameter auth role

This commit is contained in:
Methapon2001 2024-03-11 12:04:25 +07:00
parent 0e1d5f0bf8
commit f47601a356

View file

@ -5,7 +5,7 @@ import { RequestWithUser } from "./user";
export function authRole(
role: string | string[],
errorMessage = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
errorMessage: string = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
) {
return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => {
if ((Array.isArray(role) && role.includes("*")) || role === "*") return next();