Ejemplo n.º 1
0
	/**
	 * Check that the supplied password or key is valid for this user.
	 *
	 * @param string $password The password to verify
	 * @return boolean
	 */
	public function checkPassword($password){
		$hasher = new \PasswordHash(datastore::HASH_ITERATIONS);
		// The password for datastores are stored in the datastore.
		$currentpass = $this->_usermodel->get('password');

		return $hasher->checkPassword($password, $currentpass);
	}
Ejemplo n.º 2
0
Archivo: User.php Proyecto: sklww/Cinch
 /**
  * Encrypt user's password using Blowfish algorithm and bcrypt
  * @param $password
  * @param $db_pass
  * @access public
  * @return boolean
  */
 public function validatePassword($password, $db_pass)
 {
     $check_pass = new PasswordHash(8, false);
     return $check_pass->checkPassword($password, $db_pass);
 }
Ejemplo n.º 3
0
 /**
  * compare a password to a hashed password. 
  *
  * @param string
  * @param string
  * @return boolean
  */
 public function checkPassword($password, $hash)
 {
     $hasher = new PasswordHash($this->CI->config->item('hash_logarithm', 'appunto-auth/appunto_auth'), $this->CI->config->item('hash_use_portable', 'appunto-auth/appunto_auth'));
     return $hasher->checkPassword($password, $hash);
 }
Ejemplo n.º 4
0
 /**
  * @param $string
  * @param $storedHash
  * @return bool
  */
 public function checkString($string, $storedHash)
 {
     $hasher = new \PasswordHash($this->_iterationCount, false);
     $check = $hasher->checkPassword($string, $storedHash);
     return $check;
 }
Ejemplo n.º 5
0
 /**
  * Check a Vanilla hash.
  *
  * @param $Password
  * @param $StoredHash
  * @return bool
  */
 function checkVanilla($Password, $StoredHash)
 {
     $this->Weak = false;
     if (!isset($StoredHash[0])) {
         return false;
     }
     if ($StoredHash[0] === '_' || $StoredHash[0] === '$') {
         $Result = parent::checkPassword($Password, $StoredHash);
         // Check to see if this password should be rehashed to crypt-blowfish.
         if (!$this->portable_hashes && CRYPT_BLOWFISH == 1 && substr($StoredHash, 0, 3) === '$P$') {
             $this->Weak = true;
         }
         return $Result;
     } elseif ($Password && $StoredHash !== '*' && ($Password === $StoredHash || md5($Password) === $StoredHash)) {
         $this->Weak = true;
         return true;
     }
     return false;
 }
Ejemplo n.º 6
0
 /**
  * Check a password using Phpass' hash.
  *
  * @param string $Password The plaintext password to check.
  * @param string $StoredHash The password hash stored in the database.
  * @return bool Returns **true** if the password matches the hash or **false** if it doesn't.
  */
 public function checkPhpass($Password, $StoredHash)
 {
     return parent::checkPassword($Password, $StoredHash);
 }
Ejemplo n.º 7
0
 /**
  * Change user's email
  *
  * @param string $currentPassword Current user password to check if it can be changed
  * @param string $newEmail New Email
  */
 public function changeEmail($currentPassword, $newEmail)
 {
     $this->_db->beginTransaction();
     try {
         $userInfos = $this->_db->fetchFirstRequest('getUserPassword', array(':id' => $this->_userInfos['ID']));
         if (!empty($userInfos)) {
             $hasher = new PasswordHash(8, false);
             if ($hasher->checkPassword($currentPassword, $userInfos['password'])) {
                 $this->_db->executeRequest('changeUserEmail', array(':email' => $newEmail, ':id' => $this->_userInfos['ID']));
             } else {
                 $this->_messenger->add('error', $this->_lang->get('wrongPassword'));
             }
         }
     } catch (Exception $e) {
         $this->_db->rollBack();
         throw $e;
     }
     $this->_db->commit();
     return true;
 }