From 0b51b478597631689625a8d98796976c25ed87c3 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Dec 2024 00:43:49 -0500 Subject: [PATCH] Updated format --- .../VerificationAnswerImageCaptcha.php | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/VerificationAnswerImageCaptcha.php b/src/Socialbox/Classes/StandardMethods/VerificationAnswerImageCaptcha.php index 88adeb3..d5234c4 100644 --- a/src/Socialbox/Classes/StandardMethods/VerificationAnswerImageCaptcha.php +++ b/src/Socialbox/Classes/StandardMethods/VerificationAnswerImageCaptcha.php @@ -1,77 +1,77 @@ containsParameter('answer')) - { - return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The answer parameter is required'); - } - $session = $request->getSession(); - - try + /** + * @inheritDoc + */ + public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { - if(CaptchaManager::getCaptcha($session->getPeerUuid())->isExpired()) + if(!$rpcRequest->containsParameter('answer')) { - return $rpcRequest->produceError(StandardError::CAPTCHA_EXPIRED, 'The captcha has expired'); + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The answer parameter is required'); } - } - catch(DatabaseOperationException $e) - { - throw new StandardException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); - } - try - { - $result = CaptchaManager::answerCaptcha($session->getPeerUuid(), $rpcRequest->getParameter('answer')); + $session = $request->getSession(); - if($result) - { - SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_IMAGE_CAPTCHA]); - } - } - catch (DatabaseOperationException $e) - { - throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); - } - - // Check if all registration flags are removed - if(SessionFlags::isComplete($request->getSession()->getFlags())) - { - // Set the session as authenticated try { - SessionManager::setAuthenticated($request->getSessionUuid(), true); - SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::REGISTRATION_REQUIRED, SessionFlags::AUTHENTICATION_REQUIRED]); + if(CaptchaManager::getCaptcha($session->getPeerUuid())->isExpired()) + { + return $rpcRequest->produceError(StandardError::CAPTCHA_EXPIRED, 'The captcha has expired'); + } + } + catch(DatabaseOperationException $e) + { + throw new StandardException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); + } + + try + { + $result = CaptchaManager::answerCaptcha($session->getPeerUuid(), $rpcRequest->getParameter('answer')); + + if($result) + { + SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_IMAGE_CAPTCHA]); + } } catch (DatabaseOperationException $e) { - return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); } - } - return $rpcRequest->produceResponse($result); - } -} \ No newline at end of file + // Check if all registration flags are removed + if(SessionFlags::isComplete($request->getSession()->getFlags())) + { + // Set the session as authenticated + try + { + SessionManager::setAuthenticated($request->getSessionUuid(), true); + SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::REGISTRATION_REQUIRED, SessionFlags::AUTHENTICATION_REQUIRED]); + } + catch (DatabaseOperationException $e) + { + return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e); + } + } + + return $rpcRequest->produceResponse($result); + } + } \ No newline at end of file