feat: improve authentication
All checks were successful
Build Test / build (pull_request) Successful in 43s
JS Unit Tests / test (pull_request) Successful in 41s
PHP Unit Tests / test (pull_request) Successful in 49s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-19 23:03:09 -05:00
parent decda8becc
commit 99fa707eb3
7 changed files with 194 additions and 175 deletions

View File

@@ -225,7 +225,7 @@ class AuthenticationController extends ControllerAbstract
return $this->clearTokenCookies($httpResponse);
}
$httpResponse = new JsonResponse(['status' => 'success', 'message' => 'Token refreshed']);
$httpResponse = new JsonResponse(['status' => 'success', 'message' => 'Token refreshed', 'expires_in' => 900]);
if ($response->tokens && isset($response->tokens['access'])) {
$httpResponse->headers->setCookie(
@@ -242,6 +242,15 @@ class AuthenticationController extends ControllerAbstract
return $httpResponse;
}
/**
* Session health check
*/
#[AuthenticatedRoute('/auth/ping', name: 'auth.ping', methods: ['GET'])]
public function ping(): JsonResponse
{
return new JsonResponse(['status' => 'ok']);
}
/**
* Logout current device
*/
@@ -281,14 +290,16 @@ class AuthenticationController extends ControllerAbstract
*/
private function buildJsonResponse(AuthenticationResponse $response): JsonResponse
{
$httpResponse = new JsonResponse($response->toArray(), $response->httpStatus);
$data = $response->toArray();
// Set token cookies if present
// Set token cookies and expose expires_in if present
if ($response->hasTokens()) {
$data['expires_in'] = 900;
$httpResponse = new JsonResponse($data, $response->httpStatus);
return $this->setTokenCookies($httpResponse, $response->tokens, true);
}
return $httpResponse;
return new JsonResponse($data, $response->httpStatus);
}
/**