1.2.0 • Published 8 years ago
meanie-passport-refresh-strategy v1.2.0
passport-refresh-strategy
A refresh token authentication strategy for Passport, for use with Meanie Express Seed projects
Installation
You can install this package using npm
.
npm install meanie-passport-refresh-strategy --save
Usage
//Dependencies
let passport = require('passport');
let RefreshStrategy = require('meanie-passport-refresh-strategy');
//Setup strategy (where `User` is your custom user service)
passport.use(new RefreshStrategy((refreshToken, cb) => {
//No refresh token?
if (!refreshToken) {
return cb(null, false);
}
//Validate token
tokens.validate('refresh', refreshToken)
.then(User.findByTokenPayload)
.then(user => {
if (!user) {
throw new InvalidTokenError('No matching user found');
}
return cb(null, user);
})
.catch(cb);
}));
Issues & feature requests
Please report any bugs, issues, suggestions and feature requests in the meanie-passport-refresh-strategy issue tracker.
Contributing
Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.
Credits
- Meanie logo designed by Quan-Lin Sim
License
(MIT License)
Copyright 2016-2017, Adam Reis