The RequireAuth Middleware


deploys to:  app/routing/middleware/auth/RequireAuth.middleware.js         exports:  RequireAuth

class RequireAuth

Middleware that, when applied, redirects the user to the login page if they are not authenticated.

test(express.request req, express.response res, function next)

returns:  undefined

Checks if req.session.auth.user exists, or req.session.auth.authenticated is true. If these are, that means that a user is logged in. If this check passes, then call the next function in the stack, allowing the request to continue. Otherwise, write req.originalUrl to req.session.destination and redirect to the /auth/login route.

No Comments
Back to top