Skip to main content

authorize

@abimongo/core v1.1.4


@abimongo/core / authorize

Function: authorize()

authorize(roles): (req, res, next) => Response | { _id: string; role: string; tenantId: string; } | undefined

Defined in: core/src/middleware/authorization/auth.ts:17

Middleware to authorize access to routes based on user roles. This middleware checks if the request contains a valid JWT token,

Parameters

roles

string[]

An array of roles that are allowed to access the route.

Returns

(req, res, next): Response | { _id: string; role: string; tenantId: string; } | undefined

Parameters

req

Request

res

Response

next

NextFunction

Returns

Response | { _id: string; role: string; tenantId: string; } | undefined