TestAuthenticate.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. public $callStack = [];
  25. public function implementedEvents() {
  26. return [
  27. 'Auth.afterIdentify' => 'afterIdentify',
  28. 'Auth.logout' => 'logout'
  29. ];
  30. }
  31. public function authenticate(Request $request, Response $response) {
  32. return ['id' => 1, 'username' => 'admad'];
  33. }
  34. public function afterIdentify(Event $event, array $user) {
  35. $this->callStack[] = __FUNCTION__;
  36. }
  37. public function logout(Event $event, array $user) {
  38. $this->callStack[] = __FUNCTION__;
  39. }
  40. }