Ejemplo n.º 1
0
 /**
  * Sets the user password.
  *
  * @param string $password
  */
 public function setPassword($password)
 {
     if (!$password && 0 == strlen($password)) {
         return;
     }
     $fromdump = false;
     if ($this->isNew() && $this->getSalt()) {
         $fromdump = true;
     }
     if (!($salt = $this->getSalt())) {
         $salt = md5(rand(100000, 999999) . $this->getUsername());
         $this->setSalt($salt);
     }
     $modified = $this->getModified();
     if (!($algorithm = $this->getAlgorithm()) || isset($modified['algorithm']) && $modified['algorithm'] == $this->getTable()->getDefaultValueOf('algorithm')) {
         $algorithm = sfConfig::get('app_sf_guard_plugin_algorithm_callable', 'sha1');
     }
     $algorithmAsStr = is_array($algorithm) ? $algorithm[0] . '::' . $algorithm[1] : $algorithm;
     if (!is_callable($algorithm)) {
         throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithmAsStr));
     }
     $this->setAlgorithm($algorithmAsStr);
     if ($fromdump) {
         parent::_set('password', $password);
     } else {
         parent::_set('password', call_user_func_array($algorithm, array($salt . $password)));
     }
 }
 public function setPassword($password)
 {
     if (!$password && 0 == strlen($password)) {
         return;
     }
     if (!($salt = $this->getSalt())) {
         $salt = md5(rand(100000, 999999) . $this->getUsername());
         $this->setSalt($salt);
     }
     if (!($algorithm = $this->getAlgorithm())) {
         $algorithm = sfConfig::get('app_sf_guard_plugin_algorithm_callable', 'sha1');
     }
     $algorithmAsStr = is_array($algorithm) ? $algorithm[0] . '::' . $algorithm[1] : $algorithm;
     if (!is_callable($algorithm)) {
         throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithmAsStr));
     }
     $this->setAlgorithm($algorithmAsStr);
     parent::_set('password', call_user_func_array($algorithm, array($salt . $password)));
 }
Ejemplo n.º 3
0
 public function setFixturesHash($hash)
 {
     parent::_set('password', $hash);
 }