Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including passport-expresshelper with all npm packages installed. Try it out:

var passportExpresshelper = require("passport-expresshelper")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

passport-expresshelper v0.0.1

dynamicHelpers for expressjs 2.x


Helper for express 2.x in combination with the with the passport authentication module

dynamicHelper for express 2.x:

var passportexpresshelper = require('passport-expresshelper');


Middleware for express routes

var checkAuth = require('passport-expresshelper').ensureAuthenticated;

app.get('/somethingprivate', checkAuth);

If the user is authenticated through passport, the request will continue to the requested page. Otherwise the requested path will be saved to req.session.redirect and the user will be redirected to /login. If you want to forward the user to a different page, you could add another route like this:

app.get('/login', function(req, res) {

After the login, the user can be forwarded to the originally requested page using the saved path in req.session.redirect.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free