- Added some more params to the callback functions.

This commit is contained in:
Dave M. 2021-02-16 14:32:49 +00:00
parent 9508fb79f9
commit c38f47d9a7
1 changed files with 7 additions and 7 deletions

View File

@ -30,13 +30,13 @@ class Authenticate {
) {
$this->session = $session;
$this->cookie = $cookie;
$this->authenticationEvent = $authenticationEvent ?: function(bool $authenticated, string $message, ? User $user) : void {} ;
$this->authenticationEvent = $authenticationEvent ?: function(bool $authenticated, string $message, ? User $user, array $data = []) : bool {return false;} ;
}
public function rememberMe(\Ulmus\Repository $repository) : ? User
{
$logUser = function(int $id) use ($repository) {
if ( null === ( $user = $repository->loadOne($id) ) ) {
if ( null === ( $user = $repository->loadFromPk($id) ) ) {
throw new \Exception("User not found.");
}
@ -71,12 +71,12 @@ class Authenticate {
$this->user = $repository->loadOne() ?: $repository->instanciateEntity();
}
catch(Exception\EmptyDatasetException $e) {
call_user_func_array($this->authenticationEvent, [ false, 'userNotFound', $this->user ]);
if ( ! call_user_func_array($this->authenticationEvent, [ false, 'userNotFound', $this->user ]) ) {
return $repository->instanciateEntity();
}
}
if ( $this->user->isLoaded() && $this->user->verifyPassword($password) ) {
if ( $this->user->isLoaded() && ( call_user_func_array($this->authenticationEvent, [ false, 'verifyPassword', $this->user, [ 'password' => $password ] ]) || $this->user->verifyPassword($password) ) ) {
$this->user->logged = true;
if ( $this->session ) {