- WIP on authentication portal
This commit is contained in:
1 parent
1559ceb248
commit
7769b1a1ca
15 files changed
+220
-134
No files matched your search
@@ -10,27 +10,18 @@ use Ulmus\User\Entity\User;
|
||||
use Ulmus\Exception;
|
||||
|
||||
class Authenticate {
|
||||
|
||||
protected ? Session $session;
|
||||
|
||||
protected ? Cookie $cookie;
|
||||
|
||||
protected bool $logged = false;
|
||||
|
||||
protected Closure $authenticationEvent;
|
||||
|
||||
public ? User $user = null;
|
||||
|
||||
public string $connection_fields = 'email';
|
||||
|
||||
public function __construct(
|
||||
? Session $session = null,
|
||||
? Cookie $cookie = null,
|
||||
protected ? Session $session = null,
|
||||
protected ? Cookie $cookie = null,
|
||||
? Closure $authenticationEvent = null
|
||||
) {
|
||||
$this->session = $session;
|
||||
$this->cookie = $cookie;
|
||||
$this->authenticationEvent = $authenticationEvent ?: function(bool $authenticated, string $message, ? User $user, array $data = []) : ? bool {return null;} ;
|
||||
$this->authenticationEvent = $authenticationEvent ?: fn(bool $authenticated, string $message, ? User $user, array $data = []) : ? bool => null;
|
||||
}
|
||||
|
||||
public function rememberMe(\Ulmus\Repository $repository) : ? User
|
||||
@@ -41,7 +32,7 @@ class Authenticate {
|
||||
}
|
||||
|
||||
$user->logged = true;
|
||||
|
||||
|
||||
return $user;
|
||||
};
|
||||
|
||||
@@ -110,9 +101,6 @@ class Authenticate {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force user disconnection and handle memory trashing
|
||||
*/
|
||||
public function logout() : self
|
||||
{
|
||||
if ( $this->session ) {
|
||||
@@ -123,10 +111,10 @@ class Authenticate {
|
||||
$this->cookie->delete('user.id');
|
||||
}
|
||||
|
||||
if (isset($this->user)) {
|
||||
if ( isset($this->user) ) {
|
||||
$this->user->logged = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user