Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.62% |
11 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| LogoutEndpoint | |
84.62% |
11 / 13 |
|
0.00% |
0 / 1 |
2.01 | |
0.00% |
0 / 1 |
| handle | |
84.62% |
11 / 13 |
|
0.00% |
0 / 1 |
2.01 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Common\Endpoints; |
| 4 | |
| 5 | use Olz\Api\OlzTypedEndpoint; |
| 6 | |
| 7 | /** |
| 8 | * @extends OlzTypedEndpoint< |
| 9 | * ?array{}, |
| 10 | * array{ |
| 11 | * status: 'NO_SESSION'|'SESSION_CLOSED', |
| 12 | * } |
| 13 | * > |
| 14 | */ |
| 15 | class LogoutEndpoint extends OlzTypedEndpoint { |
| 16 | protected function handle(mixed $input): mixed { |
| 17 | $refresh_token = $this->authUtils()->getRefreshToken(); |
| 18 | if ($refresh_token !== null) { |
| 19 | $this->entityManager()->remove($refresh_token); |
| 20 | $this->entityManager()->flush(); |
| 21 | } |
| 22 | $this->getResponse()->headers->setCookie( |
| 23 | $this->authUtils()->createRefreshTokenCookie(null) |
| 24 | ); |
| 25 | $this->authUtils()->setSessionUser(null); |
| 26 | $this->authUtils()->setSessionAuthUser(null); |
| 27 | $this->session()->clear(); |
| 28 | return [ |
| 29 | 'status' => 'SESSION_CLOSED', |
| 30 | ]; |
| 31 | } |
| 32 | } |