generators/app/templates/server/lib/auth(auth)/local/passport.js
function getAuthentication(authModel, config) {

  /**
   * @name authenticate
   * @function
   * @memberOf getAuthentication
   * Authenticate the user.
   * @param {String} name - The name used to authenticate the user
   * @param {String} password - The hashed password
   * @param {function} done - The callback function called with an error or the valid user object
   */
  function authenticate(name, password, done) {
    authModel.findOne({name: name, active: true}, function (err, user) {
      if (err) {
        return done(err);
      }

      if (!user) {
        return done(null, false, {message: 'Unknown user'});
      }

      if (!user.authenticate(password)) {
        return done(null, false, {message: 'Wrong password'});
      }

      return done(null, user);
    });
  }

  return authenticate;
}
function getAuthentication(authModel, config) {

  /**
   * @name authenticate
   * @function
   * @memberOf getAuthentication
   * Authenticate the user.
   * @param {String} name - The name used to authenticate the user
   * @param {String} password - The hashed password
   * @param {function} done - The callback function called with an error or the valid user object
   */
  function authenticate(name, password, done) {
    authModel.findOne({name: name, active: true}, function (err, user) {
      if (err) {
        return done(err);
      }

      if (!user) {
        return done(null, false, {message: 'Unknown user'});
      }

      if (!user.authenticate(password)) {
        return done(null, false, {message: 'Wrong password'});
      }

      return done(null, user);
    });
  }

  return authenticate;
}
function getAuthentication ( authModel , config ) { /**
   * @name authenticate
   * @function
   * @memberOf getAuthentication
   * Authenticate the user.
   * @param {String} name - The name used to authenticate the user
   * @param {String} password - The hashed password
   * @param {function} done - The callback function called with an error or the valid user object
   */ function authenticate ( name , password , done ) { authModel . findOne ( { name : name , active : true } , function ( err , user ) { if ( err ) { return done ( err ) ; } if ( ! user ) { return done ( null , false , { message : 'Unknown user' } ) ; } if ( ! user . authenticate ( password ) ) { return done ( null , false , { message : 'Wrong password' } ) ; } return done ( null , user ) ; } ) ; } return authenticate ; }
Return a function that authenticates the user. The user is identified by email.
The hashed password is passed to the User model for authentication.
@param {Model} authModel - The mongoose model used to authenticate the user
@param {Object} [config] - The application configuration, may be passed to the service some day
@returns {function} - The authentication function to use with the given authModel
Return a function that authenticates the user . The user is identified by email . The hashed password is passed to the User model for authentication .