Skip to content

Commit

Permalink
to fix #74
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Richer [email protected] <[email protected]>
  • Loading branch information
visto9259 committed Jun 27, 2024
1 parent b9fdf7b commit f129e83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Authentication/Adapter/AdapterChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public function resetAdapters()
}
}
}
$event = $this->getEvent();
$event->setName('reset');
$this->getEventManager()->triggerEvent($event);

return $this;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Authentication/Adapter/AdapterChainServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, arr
if (is_callable(array($adapter, 'logout'))) {
$chain->getEventManager()->attach('logout', array($adapter, 'logout'), $priority);
}

if (is_callable(array($adapter, 'reset'))) {
$chain->getEventManager()->attach('reset', array($adapter, 'reset'), $priority);
}
}

return $chain;
Expand Down
11 changes: 11 additions & 0 deletions src/Authentication/Adapter/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public function logout(AdapterChainEvent $e)
$this->getStorage()->clear();
}

/**
* Called when authentication adapter is reset
* @param AdapterChainEvent $e
*
*/
public function reset(AdapterChainEvent $e): void
{
$this->getStorage()->clear();
}


/**
* @param AdapterChainEvent $e
* @return bool
Expand Down
10 changes: 10 additions & 0 deletions tests/Authentication/Adapter/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ public function testLogout()
$this->db->logout($this->authEvent);
}

/**
* @covers \LmcUser\Authentication\Adapter\Db::reset
*/
public function testReset()
{
$this->storage->expects($this->once())
->method('clear');
$this->db->reset($this->authEvent);
}

/**
* @covers \LmcUser\Authentication\Adapter\Db::Authenticate
*/
Expand Down

0 comments on commit f129e83

Please sign in to comment.