feat: improve authentication
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user