feathers-authentication
Advanced tools
Comparing version
@@ -5,4 +5,4 @@ var feathers = require('feathers'); | ||
var bodyParser = require('body-parser'); | ||
var feathersPassportJwt = require('../lib/passport'); | ||
var hashPassword = feathersPassportJwt.hooks.hashPassword; | ||
var feathersAuth = require('../lib/index'); | ||
var hashPassword = feathersAuth.hooks.hashPassword; | ||
@@ -16,4 +16,4 @@ // Initialize the application | ||
.use(bodyParser.urlencoded({ extended: true })) | ||
// Configure feathers-passport-jwt | ||
.configure(feathersPassportJwt({ | ||
// Configure feathers-authentication | ||
.configure(feathersAuth({ | ||
secret: 'feathers-rocks' | ||
@@ -20,0 +20,0 @@ })) |
@@ -29,4 +29,9 @@ 'use strict'; | ||
if (req.body.token) { | ||
// TODO: Move token verification into its own middleware. See line ~96. | ||
_jsonwebtoken2.default.verify(req.body.token, settings.secret, function (err, data) { | ||
if (err) { | ||
// Return a 401 Unauthorized if the token has expired. | ||
if (err.name === 'TokenExpiredError') { | ||
return res.status(401).json(err); | ||
} | ||
return next(err); | ||
@@ -75,4 +80,9 @@ } | ||
debug('Got an Authorization token', token); | ||
// TODO: Move token verification into its own middleware. See line ~44. | ||
_jsonwebtoken2.default.verify(token, settings.secret, function (err, data) { | ||
if (err) { | ||
// Return a 401 Unauthorized if the token has expired. | ||
if (err.name === 'TokenExpiredError') { | ||
return res.status(401).json(err); | ||
} | ||
return next(err); | ||
@@ -79,0 +89,0 @@ } |
{ | ||
"name": "feathers-authentication", | ||
"description": "Add Authentication to your FeathersJS app.", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "https://github.com/feathersjs/feathers-authentication", | ||
@@ -6,0 +6,0 @@ "main": "lib/", |
25417
2.01%404
2.54%