Fix terms acceptance logic and improve session handling

This commit is contained in:
netkas 2025-01-06 02:20:09 -05:00
parent 3a72363937
commit 17a151fd8a

View file

@ -14,17 +14,22 @@
class AcceptTermsOfService extends Method class AcceptTermsOfService extends Method
{ {
/** /**
* Executes the process of accepting the terms of service.
*
* @inheritDoc * @inheritDoc
*/ */
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface 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 try
{ {
// Remove the verification flag
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_TERMS_OF_SERVICE]);
// Check & update the session flow // Check & update the session flow
SessionManager::updateFlow($request->getSession()); SessionManager::updateFlow($session, [SessionFlags::VER_TERMS_OF_SERVICE]);
} }
catch (DatabaseOperationException $e) catch (DatabaseOperationException $e)
{ {