Noodle Printing Machine

    @meanie/passport-refresh-strategy

    3.1.0 • Public • Published

    @meanie/passport-refresh-strategy

    npm version node dependencies github issues codacy

    A refresh token authentication strategy for Passport

    Meanie

    Installation

    You can install this package using yarn or npm.

    #yarn
    yarn add @meanie/passport-refresh-strategy
    
    #npm
    npm install @meanie/passport-refresh-strategy --save

    Usage

    //Dependencies
    const passport = require('passport');
    const jwt = require('@meanie/express-jsonwebtoken');
    const RefreshStrategy = require('@meanie/passport-refresh-strategy');
    const {InvalidTokenError} = jwt;
    
    //Your custom user service
    const User = require('./user.service');
    
    //Setup strategy
    passport.use(new RefreshStrategy((refreshToken, cb) => {
    
      //No refresh token?
      if (!refreshToken) {
        return cb(null, false);
      }
    
      //Validate token
      jwt
        .validate(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.

    Sponsor

    This package has been kindly sponsored by Hello Club, an all in one club and membership management solution complete with booking system, automated membership renewals, online payments and integrated access and light control. Check us out if you happen to belong to any kind of club or if you know someone who helps run a club!

    License

    (MIT License)

    Copyright 2016-2020, Adam Reis

    Install

    npm i @meanie/passport-refresh-strategy

    DownloadsWeekly Downloads

    18

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    7.88 kB

    Total Files

    7

    Last publish

    Collaborators

    • adamreisnz