1.2.0 • Published 8 years ago

meanie-passport-refresh-strategy v1.2.0

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

passport-refresh-strategy

npm version node dependencies github issues codacy

A refresh token authentication strategy for Passport, for use with Meanie Express Seed projects

Meanie

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

License

(MIT License)

Copyright 2016-2017, Adam Reis

1.2.0

8 years ago

1.1.3

8 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago