The RequireGuest Middleware

flitter-auth/deploy/routing/middleware/RequireGuest.middleware.js

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

class RequireGuest

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 the errors/requires_guest view is rendered. Otherwise, the user is a guest (non-authenticated session), and the next function in the stack is called, allowing the request to continue.

No Comments
Back to top