UserIdentity.php 824 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * UserIdentity represents the data needed to identity a user.
  4. * It contains the authentication method that checks if the provided
  5. * data can identity the user.
  6. */
  7. class UserIdentity extends CUserIdentity
  8. {
  9. /**
  10. * Validates the username and password.
  11. * This method should check the validity of the provided username
  12. * and password in some way. In case of any authentication failure,
  13. * set errorCode and errorMessage with appropriate values and return false.
  14. * @param string username
  15. * @param string password
  16. * @return boolean whether the username and password are valid
  17. */
  18. public function authenticate()
  19. {
  20. if($this->username==='demo' && $this->password==='demo')
  21. $this->errorCode=self::ERROR_NONE;
  22. else
  23. $this->errorCode=self::ERROR_PASSWORD_INVALID;
  24. return !$this->errorCode;
  25. }
  26. }