diff --git a/src/Api.php b/src/Api.php index 12abb0c..807e14f 100644 --- a/src/Api.php +++ b/src/Api.php @@ -137,7 +137,7 @@ class Api public function freshLogin(int $mglnr, string $password): self { - $this->authenticator->purge(); + $this->authenticator->purge($mglnr); return $this->login($mglnr, $password); } diff --git a/src/Authentication/Authenticator.php b/src/Authentication/Authenticator.php index 3784d5a..e192a84 100644 --- a/src/Authentication/Authenticator.php +++ b/src/Authentication/Authenticator.php @@ -10,7 +10,7 @@ abstract class Authenticator 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; diff --git a/src/Authentication/FakeCookie.php b/src/Authentication/FakeCookie.php index b461034..201537d 100644 --- a/src/Authentication/FakeCookie.php +++ b/src/Authentication/FakeCookie.php @@ -67,12 +67,12 @@ class FakeCookie extends Authenticator { Assert::assertTrue( $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}" ); } - public function purge(): void + public function purge(int $mglnr): void { } @@ -84,7 +84,7 @@ class FakeCookie extends Authenticator { Assert::assertFalse( $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') ); } diff --git a/src/Authentication/MainCookie.php b/src/Authentication/MainCookie.php index b57804e..f953b07 100644 --- a/src/Authentication/MainCookie.php +++ b/src/Authentication/MainCookie.php @@ -46,8 +46,9 @@ class MainCookie extends Authenticator return $this; } - public function purge(): void + public function purge(int $mglnr): void { + $this->mglnr = $mglnr; while ($this->file()) { unlink($this->file()); }