refactor(middlewares): add type to function parameter auth role
This commit is contained in:
parent
0e1d5f0bf8
commit
f47601a356
1 changed files with 1 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ import { RequestWithUser } from "./user";
|
||||||
|
|
||||||
export function authRole(
|
export function authRole(
|
||||||
role: string | string[],
|
role: string | string[],
|
||||||
errorMessage = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
|
errorMessage: string = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
|
||||||
) {
|
) {
|
||||||
return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => {
|
return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => {
|
||||||
if ((Array.isArray(role) && role.includes("*")) || role === "*") return next();
|
if ((Array.isArray(role) && role.includes("*")) || role === "*") return next();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue