text: const passport = require('passport');
  const User = require('../models/user');
  const config = require('../config');
  const JwtStrategy = require('passport-jwt').Strategy;
  const ExtractJwt = require('passport-jwt').ExtractJwt;
  const LocalStrategy = require('passport-local')
  
  // Sign up - rejestracja
  // Sign in - logowanie
  
  // Create local strategy
  // implementation in passport-local:
  //
  //   this._usernameField = options.usernameField || 'username';
  //   this._passwordField = options.passwordField || 'password';
  
  
  
  const localOptions = {
    usernameField: 'email',
    passwordField: 'password'
  }
  
  const localLogin = new LocalStrategy(localOptions, function(email, password, done) {
    // Verify this email and password, call done with user object
    // if found ohterwise call done with false
  
    User.findOne({email: email}, function(err, user) {
      if(err) { return done(err); }
      if(!user) { return done(null, false);}
      // compare password
  
      user.comparePassword(password, function(err, isMatch) {
        if(err) { return done(err); }
        if(!isMatch) { return done(null, false); }
        return done(null, user);
      })
    });
  });
  
  // Setup options for JWT
  const jwtOptions = {
    jwtFromRequest: ExtractJwt.fromHeader('authorization'),
    secretOrKey: config.secret
  };
  
  // Create JWT strategy (payload - decoded jwt token)
  const jwtLogin = new JwtStrategy(jwtOptions, function(payload, done) {
    // See if the user ID in the payload exists in our database
    // If it does call done with that user object otherwise call done without user object
  
    User.findById(payload.sub, function(err, user) {
      if(err) {
        return done(false);
      }
  
      if(user) {
        done(null, user);
      }
      else {
        done(null, false);
      }
    });
  });
  
  // Tell passport to use this strategy
  passport.use(jwtLogin);
  passport.use(localLogin);