示例#1
0
 public function isValid()
 {
     // get db class
     $db = Knowledgeroot_Registry::get('db');
     // get user from db
     $user = $db->fetchRow("SELECT id, password FROM " . $db->quoteIdentifier('user') . " WHERE login=? AND active=?", array($this->username, Knowledgeroot_Db::true()));
     // check password hashes
     if ($user && Knowledgeroot_Password::verify($this->password, $user['password'])) {
         $this->isValid = true;
         return true;
     }
     return false;
 }
示例#2
0
 public function setPassword($password)
 {
     $hash = new Knowledgeroot_Password($password);
     $this->passwordHash = $hash->getHash();
 }
示例#3
0
 /**
  * verify password with hash value
  *
  * @param type $password
  * @param type $hash
  * @return bool
  */
 public static function verify($password, $hash)
 {
     // get  old settings from hash
     $hashArr = explode("\$", $hash);
     $method = $hashArr[1];
     $rotation = $hashArr[2];
     $salt = $hashArr[3];
     $pwHash = $hashArr[4];
     // generate hash with old values
     $verifyHash = Knowledgeroot_Password::generateHash($password, $method, $rotation, $salt);
     return $hash == $verifyHash;
 }