import {Strategy, ExtractJwt} from 'passport-jwt';
let log = require('logfilename')(__filename);

export default function register(passport, models) {
  log.debug("register");

  let opts = {};
  opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('Bearer');
  opts.secretOrKey = 'secret';
  //opts.issuer = "accounts.examplesoft.com";
  //opts.audience = "yoursite.net";

  let strategy = new Strategy(opts, async (jwtPayload, done) => {
    log.debug("findUser: ", jwtPayload);
    let user = await models.User.find({
      where: {
        id: jwtPayload.id
      }
    });

    if (!user) {
      log.info("findUser no user");
      done(null);
    } else {
      log.info("findUser ", user.get());
      done(null, user.get());
    }
  });

  passport.use('jwt', strategy);
};

@@ -44,16 +44,46 @@
 t-jwt';%0A
+import config from 'config';%0A%0A
 let log 
@@ -206,30 +206,115 @@
 %0A%0A  
-let opts = %7B%7D;%0A  opts.
+//More options at https://github.com/themikenicholson/passport-jwt#configure-strategy%0A  const opts = %7B%0A    
 jwtF
@@ -323,18 +323,17 @@
 mRequest
- =
+:
  Extract
@@ -374,17 +374,14 @@
 er')
-;%0A  opts.
+,%0A    
 secr
@@ -387,18 +387,38 @@
 retOrKey
- =
+: config.jwt.secret %7C%7C
  'secret
@@ -422,90 +422,57 @@
 ret'
-;%0A  //opts.issuer = %22accounts.examplesoft.com%22;%0A  //opts.audience = %22yoursite.net%22
+,%0A    jsonWebTokenOptions: config.jwt.options%0A  %7D
 ;%0A%0A 

use jwt secret from config