- Added some more params to the callback functions.
This commit is contained in:
parent
9508fb79f9
commit
c38f47d9a7
|
@ -30,16 +30,16 @@ class Authenticate {
|
||||||
) {
|
) {
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
$this->cookie = $cookie;
|
$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
|
public function rememberMe(\Ulmus\Repository $repository) : ? User
|
||||||
{
|
{
|
||||||
$logUser = function(int $id) use ($repository) {
|
$logUser = function(int $id) use ($repository) {
|
||||||
if ( null === ( $user = $repository->loadOne($id) ) ) {
|
if ( null === ( $user = $repository->loadFromPk($id) ) ) {
|
||||||
throw new \Exception("User not found.");
|
throw new \Exception("User not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->logged = true;
|
$user->logged = true;
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
@ -71,12 +71,12 @@ class Authenticate {
|
||||||
$this->user = $repository->loadOne() ?: $repository->instanciateEntity();
|
$this->user = $repository->loadOne() ?: $repository->instanciateEntity();
|
||||||
}
|
}
|
||||||
catch(Exception\EmptyDatasetException $e) {
|
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();
|
||||||
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;
|
$this->user->logged = true;
|
||||||
|
|
||||||
if ( $this->session ) {
|
if ( $this->session ) {
|
||||||
|
|
Loading…
Reference in New Issue