TestAuthenticate.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @since 3.0.0
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace TestApp\Auth;
  15. use Cake\Auth\BaseAuthenticate;
  16. use Cake\Event\Event;
  17. use Cake\Network\Request;
  18. use Cake\Network\Response;
  19. /**
  20. * TestAuthenticate class
  21. *
  22. */
  23. class TestAuthenticate extends BaseAuthenticate
  24. {
  25. public $callStack = [];
  26. public function implementedEvents()
  27. {
  28. return [
  29. 'Auth.afterIdentify' => 'afterIdentify',
  30. 'Auth.logout' => 'logout'
  31. ];
  32. }
  33. public function authenticate(Request $request, Response $response)
  34. {
  35. return ['id' => 1, 'username' => 'admad'];
  36. }
  37. public function afterIdentify(Event $event, array $user)
  38. {
  39. $this->callStack[] = __FUNCTION__;
  40. }
  41. public function logout(Event $event, array $user)
  42. {
  43. $this->callStack[] = __FUNCTION__;
  44. }
  45. }