containsParameter('password')) { return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'password' parameter"); } if(!Cryptography::validateSha512($rpcRequest->getParameter('password'))) { return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Invalid 'password' parameter, must be a valid SHA-512 hash"); } $session = $request->getSession(); if(!$session->flagExists(SessionFlags::VER_PASSWORD)) { return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Password verification is not required at this time'); } try { $result = PasswordManager::verifyPassword($request->getPeer()->getUuid(), $rpcRequest->getParameter('password')); SessionManager::updateFlow($request->getSession(), [SessionFlags::VER_PASSWORD]); } catch (CryptographyException) { return $rpcRequest->produceResponse(false); } catch (Exception $e) { throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($result); } }