authService->login(credentials: AuthDTO::fromRequest(request: $request)); if (!$result) { return $this->errorResponse(message: __('auth.failed'), code: 401); } return $this->successResponse(payload: new AuthResource($result['payload']), message: __('auth.logged_in')) ->withCookie( cookie( 'refresh_token', $result['refreshToken'], config('sanctum.rt_expiration') * 60, '/', config('session.domain'), config('session.secure'), true, false, 'Lax' ) ); } public function logout(): JsonResponse { $this->authService->logout(); return $this->successResponse(message: __('auth.logout')) ->withoutCookie('refresh_token'); } public function refresh(RefreshTokenRequest $request): JsonResponse { $result = $this->authService->refresh(RefreshTokenDTO::fromRequest(request: $request)); if (is_null($result)) { return $this->errorResponse(message: __('auth.unauthorized'), code: 403) ->withoutCookie('refresh_token'); } return $this->successResponse(payload: new AuthResource($result['payload'])) ->withCookie( cookie( 'refresh_token', $result['refreshToken'], config('sanctum.rt_expiration') * 60, '/', config('session.domain'), config('session.secure'), true, true, 'Lax' ) ); } }