- Added some more params to the callback functions.
This commit is contained in:
parent
9508fb79f9
commit
c38f47d9a7
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue