Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(sfConfig::get('sf_plugins_dir').'/sfDoctrineGuardPlugin/lib/validator/sfGuardValidatorUser.class.php');
- class mySfGuardValidatorUser extends sfGuardValidatorUser
- {
- public function configure($options = array(), $messages = array())
- {
- $this->addOption('username_field', 'username');
- $this->addOption('password_field', 'password');
- $this->addOption('throw_global_error', false);
- }
- protected function doClean($values)
- {
- $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
- $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
- $ldap = myLDAPBind::bind($username, $password);
- switch($ldap)
- {
- case 2:
- $this->setMessage('invalid', 'Your account is not authorized.');
- break;
- case 1:
- $this->setMessage('invalid', 'The username and/or password is invalid.');
- break;
- case 0:
- return true;
- break;
- }
- throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement