Add purge for login

This commit is contained in:
Philipp Lang 2023-05-05 12:01:32 +02:00
parent a41b190cc2
commit 75983ebb4b
4 changed files with 20 additions and 0 deletions

View File

@ -106,6 +106,13 @@ class Api
return $this;
}
public function freshLogin(int $mglnr, string $password): self
{
$this->authenticator->purge();
return $this->login($mglnr, $password);
}
public function isLoggedIn(): bool
{
return $this->authenticator->isLoggedIn();

View File

@ -8,6 +8,8 @@ abstract class Authenticator
{
abstract public function login(int $mglnr, string $password): self;
abstract public function purge(): void;
abstract public function http(): PendingRequest;
abstract public function isLoggedIn(): bool;

View File

@ -72,6 +72,10 @@ class FakeCookie extends Authenticator
);
}
public function purge(): void
{
}
public function refresh(): void
{
}

View File

@ -47,6 +47,13 @@ class MainCookie extends Authenticator
return $this;
}
public function purge(): void
{
while ($this->file()) {
unlink($this->file());
}
}
public function isLoggedIn(): bool
{
if (null === $this->file()) {