Example #1
0
File: Auth.js Project: sgiacosa/phs
 usuarios.findOne({ username: req.body.username }, function (err, user) {
   if (err) throw (err);
   //if is invalid, return 401
   if (!user) {
     res.status(401).send('Usuario o contraseña incorrecta');
     return true;
   }
   else {
     bcrypt.compare(req.body.password, user.password, function (err, isCorrect) {
       if (!isCorrect) {
         res.status(401).send('Usuario o contraseña incorrecta.');
         return true;
       }
       else {
         /*var fbToken = null;
         try {
           //obtengo el token de firebase
           var auth = fb.instance.auth();
           fbToken = auth.createCustomToken(user.username, { "premium_account": true });
         }
         catch (e) {
           console.log(e);
         }*/
         var profile = {
           username: user.username,
           nombre: user.nombre,
           apellido: user.apellido,
           firebase: null,
           aplicaciones: user.aplicaciones
         }
         var token = jwt.sign(profile, secret, { expiresIn: 3600 * 12 });
         res.json({ token: token });
       }
     });
   }
 });
Example #2
0
  this.db.get(sql,  [request.payload.username], (err, result) => {
    if (err) {
      throw err;
    }

    const user = result;
    if (!user) {
      return reply('Not authorized').code(401);
    }

    Bcrypt.compare(request.payload.password, user.password, (err, res) => {
      if (err) {
        throw err;
      }
      if (!res) {
        return reply('Not authorized').code(401);
      }
      console.log("user.id = " + user.id);
      reply({
        token: user.token,
        id: user.id
      });
    });
  });
Example #3
0
File: login.js Project: kwaugh/blog
 USERS.findOne({'username': req.param('username')}, function(err, doc){
   if(err || !doc){
     console.log('There was an error when logging in');
     res.render('login', {loginError: INVALID_LOGIN});
   }
   else{
     bcrypt.compare(req.param('password'), doc.password, function(err, result){
       if(result){
         req.session.name = doc.name;
         req.session.username = req.param('username');
         req.session.isLoggedIn = true;
         if (req.session.redirectLoc) {
             var redirectLoc = req.session.redirectLoc;
             req.session.redirectLoc = null;
             res.redirect(redirectLoc);
         } else {
             res.redirect('/welcome'); 
         }
       }
       else
         res.render('login', {loginError: INVALID_LOGIN});
     });
   }
 });   
Example #4
0
 comparePassword: function(attemptedPassword, callback) {
   bcrypt.compare(attemptedPassword, this.get('password'), function(err, isMatch) {
     callback(isMatch);
   });
 },
Example #5
0
var comparePassword = function(attemptedPassword, hashedPassword, callback) {
  console.log('THIS!!!!!', this);
  bcrypt.compare(attemptedPassword, hashedPassword, function(err, isMatch) {
    callback(isMatch);
  });
};
Example #6
0
userSchema.methods.comparePassword = function(candidatePassword, cb) {
  bcrypt.compare(candidatePassword, this.password, function(err, isMatch) {
    if (err) return cb(err);
    cb(null, isMatch);
  });
};
Example #7
0
UserSchema.methods.comparePasswords = function(password, callback) {
    bcrypt.compare(password, this.password, callback);
};
Example #8
0
 return new Promise((resolve, reject) => {
   bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
     if (err || !isMatch) reject("Senha inválida");
     resolve();
   });
 });
Example #9
0
User.prototype.comparePassword = function(passwordAttempt, callback){
  bcrypt.compare(passwordAttempt, this.password, function(err, isMatch) {
      callback(isMatch);
    });
};
Example #10
0
userSchema.methods.validatePassword = function(password, done) {
    bcrypt.compare(password, this.password, function(err, isMatch) {
        done(err, isMatch);
    });
};
Example #11
0
 testPassword: function (password, done) {
   bcrypt.compare(password, this.password, done);
 },
Example #12
0
userSchema.methods.comparePassword = function (dbpass, inpass, callback) {
  bcrypt.compare(inpass, dbpass, function(err, isMatch) {
    callback(isMatch);
  });
}
Example #13
0
 checkPassword : function (attempt, cb) {
   bcrypt.compare (attempt, this.get('password'), function (err, res) {
     err ? console.log ('Error in bCrypt Compare: ' + err) : cb (res);
   });
 }
Example #14
0
UserSchema.methods.validPassword = function validPassword(password, cb) {
  return bcrypt.compare(password, this.password, cb);
};
Example #15
0
EmployeeSchema.methods.comparePassword = function (Password, callback) {
    bcrypt.compare(Password, this.Password, callback);
};
Example #16
0
password.prototype.compare = function (item, candidate, callback) {
	if (typeof callback !== 'function') throw new Error('Password.compare() requires a callback function.');
	var value = item.get(this.path);
	if (!value) return callback(null, false);
	bcrypt.compare(candidate, item.get(this.path), callback);
};
Example #17
0
userSchema.methods.comparePassword = function(candidatePassword, callback) {
  bcrypt.compare(candidatePassword, this.password, function(err, isMatch) {
    if(err) { return callback(err); }
    callback(null, isMatch);
  });
}
Example #18
0
 return new Promise((resolve, reject) => {
   BCrypt.compare(password, this.password, function(err, res) {
     if(err) reject()
     else resolve(res)
   })
 })
Example #19
0
userSchema.methods.comparePassword = function(guess, cb) {
    bcrypt.compare(guess, this.password, function(err, isMatch) {
        if (err) { return cb(err); }
        cb(null, isMatch);
    });
};
Example #20
0
User.prototype.comparePassword = function(attemptedPassword, callback) {
  bcrypt.compare(attemptedPassword, this.password, function(err, isMatch) {
    if(err){ return callback(err); }
    callback(isMatch);
  });
};
Example #21
0
userSchema.methods.comparePassword = function (candidatePassword, cb) {
  bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
    cb(err, isMatch);
  });
};
Example #22
0
function validatePassword(password, done) {
    bcrypt.compare(password, this.password, function (err, isMatch) {
        done(err, isMatch);
    });
};
Example #23
0
userSchema.methods.validPassword = function(password, next) {
    return bcrypt.compare(password, this.local.password, next);
};
Example #24
0
var comparePassword = function (password, encryptedPassWord, callback){
  bcrypt.compare(password, encryptedPassWord, function(err, result){
    if(err){throw err;}
    return callback(result);
  });
}
Example #25
0
UserSchema.methods.verifyPassword = function(password, cb) {
  bcrypt.compare(password, this.password, function(err, isMatch) {
    if (err) return cb(err);
    cb(null, isMatch);
  });
};
Example #26
0
 validatePassword: function (password, hash, cb) {
   bcrypt.compare(password, hash, cb);
 },
Example #27
0
UserSchema.methods.checkPassword = (password, next) => {
  bcrypt.compare(password, this.password, (err, isMatch) => {
    if (err) return next(err)
    next(isMatch)
  })
}
Example #28
0
 validPwd: function(pwd, cb) {
   bcrypt.compare(pwd, this.pwd, function(err, res) {
     cb(res);
   });
 }
Example #29
0
userSchema.methods.comparePassword = function(attemptedPassword, callback) {
  bcrypt.compare(attemptedPassword, this.password, function(err, isMatch) {
    callback(isMatch);
  });
};
userSchema.methods.checkPassword = function (guess, done) {
    bcrypt.compare(guess, this.password, function (err, isMatch) {
        done(err, isMatch);
    });
};