Skip to content
Permalink
Browse files

Include authentication provider instance in Auth.afterIdentify event …

…data.
  • Loading branch information...
ADmad committed Dec 2, 2015
1 parent 754f4a2 commit 8b746c5ed0d4107c8a9437fd6c24d691302f6892
@@ -697,7 +697,7 @@ protected function _getUser()
$result = $auth->getUser($this->request);
if (!empty($result) && is_array($result)) {
$this->_authenticationProvider = $auth;
$event = $this->dispatchEvent('Auth.afterIdentify', [$result]);
$event = $this->dispatchEvent('Auth.afterIdentify', [$result, $auth]);
if ($event->result !== null) {
$result = $event->result;
}
@@ -769,7 +769,7 @@ public function identify()
$result = $auth->authenticate($this->request, $this->response);
if (!empty($result) && is_array($result)) {
$this->_authenticationProvider = $auth;
$event = $this->dispatchEvent('Auth.afterIdentify', [$result]);
$event = $this->dispatchEvent('Auth.afterIdentify', [$result, $auth]);
if ($event->result !== null) {
return $event->result;
}
@@ -1156,6 +1156,10 @@ public function testEventTriggering()
$this->assertEquals($expected, $authObject->callStack);
$expected = ['id' => 1, 'username' => 'admad'];
$this->assertEquals($expected, $user);
$this->assertInstanceOf(
'TestApp\Auth\TestAuthenticate',
$authObject->authenticationProvider
);
// Callback for Auth.afterIdentify returns a value
$authObject->modifiedUser = true;
@@ -27,6 +27,8 @@ class TestAuthenticate extends BaseAuthenticate
public $callStack = [];
public $authenticationProvider;
public function implementedEvents()
{
return [
@@ -43,6 +45,7 @@ public function authenticate(Request $request, Response $response)
public function afterIdentify(Event $event, array $user)
{
$this->callStack[] = __FUNCTION__;
$this->authenticationProvider = $event->data[1];
if (!empty($this->modifiedUser)) {
return $user + ['extra' => 'foo'];

0 comments on commit 8b746c5

Please sign in to comment.
You can’t perform that action at this time.