Fix: Purge login

This commit is contained in:
philipp lang 2024-02-28 00:31:49 +01:00
parent 0dd2c64c38
commit dfd3fbb6ee
4 changed files with 7 additions and 6 deletions

View File

@ -137,7 +137,7 @@ class Api
public function freshLogin(int $mglnr, string $password): self public function freshLogin(int $mglnr, string $password): self
{ {
$this->authenticator->purge(); $this->authenticator->purge($mglnr);
return $this->login($mglnr, $password); return $this->login($mglnr, $password);
} }

View File

@ -10,7 +10,7 @@ abstract class Authenticator
abstract public function login(int $mglnr, string $password): self; abstract public function login(int $mglnr, string $password): self;
abstract public function purge(): void; abstract public function purge(int $mglnr): void;
abstract public function http(): PendingRequest; abstract public function http(): PendingRequest;

View File

@ -67,12 +67,12 @@ class FakeCookie extends Authenticator
{ {
Assert::assertTrue( Assert::assertTrue(
$mglnr !== data_get($this->authenticated, 'mglnr') $mglnr !== data_get($this->authenticated, 'mglnr')
|| $password !== data_get($this->authenticated, 'password'), || $password !== data_get($this->authenticated, 'password'),
"Failed asserting that user {$mglnr} is not loggedd in with {$password}" "Failed asserting that user {$mglnr} is not loggedd in with {$password}"
); );
} }
public function purge(): void public function purge(int $mglnr): void
{ {
} }
@ -84,7 +84,7 @@ class FakeCookie extends Authenticator
{ {
Assert::assertFalse( Assert::assertFalse(
$this->isLoggedIn(), $this->isLoggedIn(),
'Failed asserting that noone is logged in. Found login with '.data_get($this->authenticated, 'mglnr') 'Failed asserting that noone is logged in. Found login with ' . data_get($this->authenticated, 'mglnr')
); );
} }

View File

@ -46,8 +46,9 @@ class MainCookie extends Authenticator
return $this; return $this;
} }
public function purge(): void public function purge(int $mglnr): void
{ {
$this->mglnr = $mglnr;
while ($this->file()) { while ($this->file()) {
unlink($this->file()); unlink($this->file());
} }