Comparing version 0.0.9 to 0.0.10
@@ -7,2 +7,5 @@ var ExpressRouter = require('express').Router, | ||
var Router = function(options) { | ||
if (typeof options.onAuthenticated !== 'function') throw 'AuthBase Router requires onAuthenticated(req, res) callback'; | ||
if (typeof options.onError !== 'function') throw 'AuthBase Router requires onError(err, req, res, next) callback'; | ||
var router = ExpressRouter(); | ||
@@ -22,8 +25,9 @@ | ||
router.get('/authbase/return', function(req, res) { | ||
router.get('/authbase/return', function(req, res, next) { | ||
try { | ||
req.user = jwt.decode(req.query.token, options.secret).sub; | ||
options.onAuthenticated(req, res); | ||
} catch(e) { | ||
console.error('AuthBase error:', e); | ||
} catch(err) { | ||
console.error('AuthBase error:', err.stack || err); | ||
options.onError(err, req, res, next); | ||
} | ||
@@ -30,0 +34,0 @@ }); |
{ | ||
"name": "authbase", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "AuthBase API Client and Router", | ||
@@ -5,0 +5,0 @@ "main": "./lib", |
@@ -70,2 +70,3 @@ var expect = require('expect.js'), | ||
expect(user).to.be(undefined); | ||
expect(err).to.eql({error: 'this is an error'}); | ||
mock.done(); | ||
@@ -72,0 +73,0 @@ done(); |
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
7346
203