express-authen
Advanced tools
Comparing version 1.0.3 to 2.0.0
14
index.js
@@ -26,3 +26,3 @@ function mergeOptions (defaultOpt, options) { | ||
*/ | ||
exports = module.exports = function requireLogin (options) { | ||
var old_version = function requireLogin (options) { | ||
// merge with default options | ||
@@ -60,2 +60,12 @@ options = mergeOptions({ | ||
} | ||
} | ||
}; | ||
exports = module.exports = (options)=>{ | ||
if(typeof options.user === 'object'){ | ||
//this is the latest update use config | ||
return require('./new')(options); | ||
} | ||
else{ | ||
return old_version(options); | ||
} | ||
}; |
{ | ||
"name": "express-authen", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Auto redirect to login page middleware for Expressjs", | ||
@@ -16,3 +16,8 @@ "main": "index.js", | ||
"authen", | ||
"login" | ||
"login", | ||
"persist login", | ||
"auth", | ||
"auto redirect", | ||
"redirect", | ||
"middleware" | ||
], | ||
@@ -22,2 +27,9 @@ "author": { | ||
}, | ||
"contributors":[ | ||
{ | ||
"name":"Mustafa Segun", | ||
"email": "segsalerty@gmail.com", | ||
"url": "https://github.com/segsalerty2013" | ||
} | ||
], | ||
"license": "MIT", | ||
@@ -24,0 +36,0 @@ "bugs": { |
@@ -7,2 +7,4 @@ # express-authen | ||
[![npm version](https://badge.fury.io/js/express-authen.svg)](http://badge.fury.io/js/express-authen) | ||
# Installation | ||
@@ -23,3 +25,3 @@ | ||
## Example | ||
## Example for v2.x.x | ||
@@ -29,2 +31,38 @@ ```javascript | ||
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: | ||
No | Property | Default value | Description | | ||
--- | --- | --- | --- | | ||
1 | `user` | `{}` | Object with keys to user identity which represent the session name to validate | | ||
2 | `default_page` | `/` | neutral page or homepage of the app that maybe not require any authentication | | ||
3 | `excepts` | `[]` | an array - non-required auth page | | ||
4 | `auto_refer` | `boolean` | (Optional) true or false to redirect or resume to refered page on login | ||
5 | `referer` | `referer` | session' key for save the referer page | | ||
## Example for v1.x.x | ||
```javascript | ||
var authen = require('express-authen') | ||
app.use(authen({ | ||
'login': '/', | ||
@@ -38,3 +76,3 @@ 'home': '/home', | ||
## authen(options) | ||
## authen 1.x.x (options) | ||
`options` is an object for config middleware. `options` includes: | ||
@@ -41,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9750
6
138
86