/** * 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))); } }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return sfGuardUserPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new sfGuardUserPeer(); } return self::$peer; }
public function delete($con = null) { // delete profile if available try { if ($profile = $this->getProfile()) { $profile->delete(); } } catch (sfException $e) { } return parent::delete(); }