flitter-auth/deploy/routing/middleware/RequireAuth~ Role

This middleware is provided by Flitter-auth. It will redirect the user back to their previous location if the does not have the specified role.


test(req, res, next, role)


Run the middleware's check. If an authenticated session exists and the user has the specified role, let the request continue. If an authenticated session doesn't exist, write the destination to the session and redirect the user to the login page. If the role doesn't exist, show a 401.

Name Type Description
req Express/Request

the incoming Express request

res Express/Response

the corresponding Express response

next function

Express handler stack callback. This should be called if the middleware check passed to allow the request to continue.

role string

Name of the role to require