From 17a151fd8a641be179d0e979cd75eaf714dce765 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 6 Jan 2025 02:20:09 -0500 Subject: [PATCH] Fix terms acceptance logic and improve session handling --- .../StandardMethods/AcceptTermsOfService.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/AcceptTermsOfService.php b/src/Socialbox/Classes/StandardMethods/AcceptTermsOfService.php index 2732c2e..c79f643 100644 --- a/src/Socialbox/Classes/StandardMethods/AcceptTermsOfService.php +++ b/src/Socialbox/Classes/StandardMethods/AcceptTermsOfService.php @@ -14,17 +14,22 @@ class AcceptTermsOfService extends Method { /** + * Executes the process of accepting the terms of service. + * * @inheritDoc */ public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { + $session = $request->getSession(); + if(!$session->flagExists(SessionFlags::VER_TERMS_OF_SERVICE)) + { + return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Terms of service has already been accepted'); + } + try { - // Remove the verification flag - SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_TERMS_OF_SERVICE]); - // Check & update the session flow - SessionManager::updateFlow($request->getSession()); + SessionManager::updateFlow($session, [SessionFlags::VER_TERMS_OF_SERVICE]); } catch (DatabaseOperationException $e) {