/** * Handle state logout: parse input and call logout for given user. * * @throws MissingField_RublonClientException * @throws RublonException */ protected function handleStateLogout() { if ($input = file_get_contents("php://input")) { $message = RublonSignatureWrapper::parseMessage($input, $this->getRublon()->getSecretKey()); $requiredFields = array(self::FIELD_LOGOUT_ACCESS_TOKEN, self::FIELD_LOGOUT_USER_ID, self::FIELD_LOGOUT_DEVICE_ID); foreach ($requiredFields as $field) { if (empty($message[$field])) { $response = array('status' => 'ERROR', 'msg' => 'Missing field.', 'field' => $field); break; } } if (empty($response)) { $this->handleLogout($message['userId'], $message['deviceId']); $response = array('status' => 'OK', 'msg' => 'Success'); } } else { $response = array('status' => 'ERROR', 'msg' => 'Empty JSON input.'); } header('content-type: application/json'); echo json_encode($response); exit; }
/** * Get System Token from base64 parameter. * * @param string $data Base64 decoded data * @return bool If the sign is valid return true the false * @throws RublonException */ protected function parseSystemToken($data) { $body = RublonSignatureWrapper::parseMessage(base64_decode(urldecode($data)), $this->getTempKey()); return $body[self::FIELD_SYSTEM_TOKEN]; }