コード例 #1
0
ファイル: PcUser.php プロジェクト: ntemple/intelli-plancake
 /**
  * @param string $plainPassword - the plain password to set
  */
 public function setPassword($plainPassword)
 {
     $salt = PcUtils::generateRandomString(12);
     $this->setSalt($salt);
     parent::setEncryptedPassword(PcUtils::createEncryptedPassword($plainPassword, $salt));
     return $this;
 }
コード例 #2
0
 /**
  * Checks whether the authentication by a user is correct and returns the
  * correct PcUser object in the case of correct authentication
  *
  * @param string $email - the email address
  * @param string $password - the plain password (no encryption)
  * @return boolean|PcUser, false if the details are not correct, the correct PcUser otherwise
  */
 public static function isCorrectAuthentication($email, $password)
 {
     // query to retrieve the salt, if the user exists
     $c = new Criteria();
     $c->add(PcUserPeer::EMAIL, $email, Criteria::EQUAL);
     $user = PcUserPeer::doSelectOne($c);
     if (!is_object($user)) {
         // the email address doesn't exist
         return false;
     }
     $salt = $user->getSalt();
     $c = new Criteria();
     $c->add(PcUserPeer::EMAIL, $email, Criteria::EQUAL);
     $c->add(PcUserPeer::ENCRYPTED_PASSWORD, PcUtils::createEncryptedPassword($password, $salt), Criteria::EQUAL);
     $user = PcUserPeer::doSelectOne($c);
     return is_object($user) ? $user : false;
 }