Made message signing in Cryptography use SHA512 as the message content for... #1
3 changed files with 32 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
||||||
use Socialbox\Enums\Flags\SessionFlags;
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Managers\SessionManager;
|
use Socialbox\Managers\SessionManager;
|
||||||
use Socialbox\Objects\ClientRequest;
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
@ -20,8 +21,15 @@
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$session = $request->getSession();
|
$session = $request->getSession();
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to retrieve session', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
if(!$session->flagExists(SessionFlags::VER_COMMUNITY_GUIDELINES))
|
if(!$session->flagExists(SessionFlags::VER_COMMUNITY_GUIDELINES))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Community guidelines has already been accepted');
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Community guidelines has already been accepted');
|
||||||
|
@ -34,7 +42,7 @@
|
||||||
}
|
}
|
||||||
catch (DatabaseOperationException $e)
|
catch (DatabaseOperationException $e)
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardRpcException('Failed to update session flow', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(true);
|
return $rpcRequest->produceResponse(true);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use Socialbox\Enums\Flags\SessionFlags;
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Managers\SessionManager;
|
use Socialbox\Managers\SessionManager;
|
||||||
use Socialbox\Objects\ClientRequest;
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
@ -19,8 +20,16 @@
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$session = $request->getSession();
|
$session = $request->getSession();
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to retrieve session', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$session->flagExists(SessionFlags::VER_PRIVACY_POLICY))
|
if(!$session->flagExists(SessionFlags::VER_PRIVACY_POLICY))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Privacy policy has already been accepted');
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Privacy policy has already been accepted');
|
||||||
|
@ -33,7 +42,7 @@
|
||||||
}
|
}
|
||||||
catch (DatabaseOperationException $e)
|
catch (DatabaseOperationException $e)
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardRpcException('Failed to update session flow', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(true);
|
return $rpcRequest->produceResponse(true);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use Socialbox\Enums\Flags\SessionFlags;
|
use Socialbox\Enums\Flags\SessionFlags;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
|
use Socialbox\Exceptions\Standard\StandardRpcException;
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Managers\SessionManager;
|
use Socialbox\Managers\SessionManager;
|
||||||
use Socialbox\Objects\ClientRequest;
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
@ -19,8 +20,16 @@
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$session = $request->getSession();
|
$session = $request->getSession();
|
||||||
|
}
|
||||||
|
catch (DatabaseOperationException $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to retrieve session', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$session->flagExists(SessionFlags::VER_TERMS_OF_SERVICE))
|
if(!$session->flagExists(SessionFlags::VER_TERMS_OF_SERVICE))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Terms of service has already been accepted');
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Terms of service has already been accepted');
|
||||||
|
@ -33,7 +42,7 @@
|
||||||
}
|
}
|
||||||
catch (DatabaseOperationException $e)
|
catch (DatabaseOperationException $e)
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardRpcException('Failed to update session flow', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(true);
|
return $rpcRequest->produceResponse(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue