diff --git a/src/Socialbox/Classes/StandardMethods/AcceptCommunityGuidelines.php b/src/Socialbox/Classes/StandardMethods/AcceptCommunityGuidelines.php index 6694bfd..0bb9370 100644 --- a/src/Socialbox/Classes/StandardMethods/AcceptCommunityGuidelines.php +++ b/src/Socialbox/Classes/StandardMethods/AcceptCommunityGuidelines.php @@ -21,7 +21,8 @@ */ public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { - if(!$request->getSession()->flagExists(SessionFlags::VER_COMMUNITY_GUIDELINES)) + $session = $request->getSession(); + if(!$session->flagExists(SessionFlags::VER_COMMUNITY_GUIDELINES)) { return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Community guidelines has already been accepted'); } @@ -29,7 +30,7 @@ try { // Check & update the session flow - SessionManager::updateFlow($request->getSession(), [SessionFlags::VER_COMMUNITY_GUIDELINES]); + SessionManager::updateFlow($session, [SessionFlags::VER_COMMUNITY_GUIDELINES]); } catch (DatabaseOperationException $e) { diff --git a/src/Socialbox/Classes/StandardMethods/AcceptPrivacyPolicy.php b/src/Socialbox/Classes/StandardMethods/AcceptPrivacyPolicy.php index a09c5cd..feb5811 100644 --- a/src/Socialbox/Classes/StandardMethods/AcceptPrivacyPolicy.php +++ b/src/Socialbox/Classes/StandardMethods/AcceptPrivacyPolicy.php @@ -13,19 +13,23 @@ class AcceptPrivacyPolicy extends Method { - /** + * Executes the process of accepting the privacy policy. + * * @inheritDoc */ public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { + $session = $request->getSession(); + if(!$session->flagExists(SessionFlags::VER_PRIVACY_POLICY)) + { + return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Privacy policy has already been accepted'); + } + try { - // Remove the verification flag - SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_PRIVACY_POLICY]); - // Check & update the session flow - SessionManager::updateFlow($request->getSession()); + SessionManager::updateFlow($session, [SessionFlags::VER_PRIVACY_POLICY]); } catch (DatabaseOperationException $e) {