本文整理汇总了PHP中sfGuardUser::setSalt方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setSalt方法的具体用法?PHP sfGuardUser::setSalt怎么用?PHP sfGuardUser::setSalt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setSalt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doClean
protected function doClean($values)
{
$username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
bhLDAP::debug('######## Username: ' . $username);
$password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
bhLDAP::debug('######## User exists?');
$user = Doctrine::getTable('sfGuardUser')->findOneByUsername($username);
// bhLDAP::debugDump($user, "user:");
if (!$user) {
if (bhLDAP::checkPassword($username, $password)) {
// pretend the user exists, then check AD password
bhLDAP::debug('######## User does not exist. Creating dummy user.');
$user = new sfGuardUser();
$user->setUsername($username);
$user->setSalt('unused');
$user->setPassword('unused');
$user->setUserProfile(new UserProfile());
$user->save();
}
return array_merge($values, array('user' => $user));
}
// password is ok?
bhLDAP::debug('######## Checking Password...');
if ($user->checkPassword($password)) {
bhLDAP::debug('######## Check Password successful...');
return array_merge($values, array('user' => $user));
}
bhLDAP::debug('######## Check Password failed...');
if ($this->getOption('throw_global_error')) {
throw new sfValidatorError($this, 'invalid');
}
throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
}