hapi-auth-cookie
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -106,2 +106,8 @@ // Load modules | ||
if (settings.redirectOnTry === false && // Defaults to true | ||
request.auth.mode === 'try') { | ||
return reply(err, result); | ||
} | ||
var redirectTo = settings.redirectTo; | ||
@@ -108,0 +114,0 @@ if (request.route.plugins['hapi-auth-cookie'] && |
{ | ||
"name": "hapi-auth-cookie", | ||
"description": "Cookie authentication plugin", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/spumko/hapi-auth-cookie", |
@@ -26,2 +26,4 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a> | ||
parameter name `'next'`. Set to a string to use a different parameter name. Defaults to `false`. | ||
- `redirectOnTry` - if `false` and route authentication mode is `'try'`, authentication errors will not trigger a redirection. Requires **hapi** | ||
version 6.2.0 or newer. Defaults to `true`; | ||
- `validateFunc` - an optional session validation function used to validate the content of the session cookie on each request. Used to verify that the | ||
@@ -113,3 +115,3 @@ internal session state is still valid (e.g. user account still exists). The function has the signature `function(session, callback)` where: | ||
server.pack.require('hapi-auth-cookie', function (err) { | ||
server.pack.register(require('hapi-auth-cookie'), function (err) { | ||
@@ -116,0 +118,0 @@ server.auth.strategy('session', 'cookie', { |
@@ -196,3 +196,3 @@ // Load modules | ||
it('authenticates a request', function (done) { | ||
it('logs in and authenticates a request', function (done) { | ||
@@ -512,2 +512,35 @@ var server = new Hapi.Server(); | ||
it('skips when redirectOnTry is false in try mode', function (done) { | ||
var server = new Hapi.Server(); | ||
server.pack.register(require('../'), function (err) { | ||
expect(err).to.not.exist; | ||
server.auth.strategy('default', 'cookie', 'try', { | ||
password: 'password', | ||
ttl: 60 * 1000, | ||
redirectOnTry: false, | ||
redirectTo: 'http://example.com/login', | ||
appendNext: true | ||
}); | ||
server.route({ | ||
method: 'GET', | ||
path: '/', | ||
handler: function (request, reply) { | ||
return reply(request.auth.isAuthenticated); | ||
} | ||
}); | ||
server.inject('/', function (res) { | ||
expect(res.statusCode).to.equal(200); | ||
expect(res.result).to.equal(false); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('sends to login page (uri with query)', function (done) { | ||
@@ -514,0 +547,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
38038
663
161