Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-authen

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-authen

Auto redirect to login page middleware for Expressjs

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

express-authen

Auto redirect to login page middleware for Expressjs. The main features:

  1. Auto redirect to login page when access the required-logged-in page
  2. Save the referer into session before redirect to login page

npm version

Installation

$ npm install express-authen

If you want to save this module into the package.json, simply use:

$ npm install --save express-authen

API

This middleware uses session to check wherether user logged-in or not, and save the referer before redirecting to login page. So, you should declare it after declaring the session middleware.

Example for v2.x.x

var authen = require('express-authen')
app.use(authen({
    'user': {
        'member':{
            'login':'/',
            'logout':'/customers/logout',
            'home':'/customers/dashboard'
        },
        'admin':{
            'login':'/admin/login',
            'logout':'/admin/logout',
            'home':'/admin/home'
        }
    },
    'default_page':'/',
    'auto_refer':true,
    'referer': 'referer',
    'excepts':['/api/list/members', '/api/add/members']
}))

authen 2.x.x (options)

options is an object for config middleware. options includes:

NoPropertyDefault valueDescription
1user{}Object with keys to user identity which represent the session name to validate
2default_page/neutral page or homepage of the app that maybe not require any authentication
3excepts[]an array - non-required auth page
4auto_referboolean(Optional) true or false to redirect or resume to refered page on login
5refererreferersession' key for save the referer page

Example for v1.x.x

var authen = require('express-authen')
app.use(authen({
    'login': '/',
    'home': '/home',
    'user': 'user',
    'referer': 'referer',
}))

authen 1.x.x (options)

options is an object for config middleware. options includes:

NoPropertyDefault valueDescription
1login/loginlogin page path
2home/default redirected page after logged-in
3excepts[]an array - non-required auth page
4userusersession' key for determine wherether user logged-in
5refererreferersession' key for save the referer page

License

MIT

Keywords

FAQs

Package last updated on 10 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc