0.1.0 • Published 8 years ago
passport-login-check v0.1.0
passport-login-check
This middleware ensures that a user is logged in. If a request is received where the user is unauthenticated, the request will be redirected to a login page.
Install
$ npm install passport-login-check
Usage
index.js
var l = require('passport-login-check')
//If req is unauthenticated, user will be redirected to this
l.defaultRedirectUrl = '/login'
//If req is unauthenticated, user will be returned to this after authentication
l.defaultReturnUrl = '/'
//Will redirect to defaultRedirectUrl if req is unauthenticated and return to defaultReturnUrl
app.use('/profile', l.loggedIn())
//Will return to /settings after authentication
app.use('/settings', l.loggedIn('/settings'))
//Will redirect to /auth/authentication if req is unauthenticated and return to /profile after authentication
app.use('/user/:id', l.loggedIn('/profile', '/auth/facebook'))
TODO
- Return to original URL if returnUrl is not specified
- URL Blacklisting
- Roles
Credits
License
Copyright (c) 2016 Vishnu R Menon [http://vishnurmenon.com/](http://vishnurmenon.com/)