Remove subscription levels; license valid = subscribed
This commit is contained in:
@@ -189,27 +189,9 @@ bool parseLicenseJson(const std::string& body, LicenseInfo& out) {
|
||||
out.key = root.stringField("key");
|
||||
out.email_address = root.stringField("email_address");
|
||||
|
||||
// subscription_level is an object {id,name,description} in the updated API
|
||||
// and a bare level-name string in the current one. Tolerate both, plus a
|
||||
// flat {subscription_level, subscription_level_id, subscription_level_description}.
|
||||
const radiantwave::json::JsonValue* level = root.find("subscription_level");
|
||||
if (level && level->type == radiantwave::json::JsonValue::Type::Object) {
|
||||
out.subscription_level.id = static_cast<int>(level->numberField("id"));
|
||||
out.subscription_level.name = level->stringField("name");
|
||||
out.subscription_level.description = level->stringField("description");
|
||||
} else if (level && level->type == radiantwave::json::JsonValue::Type::String) {
|
||||
out.subscription_level.name = level->str;
|
||||
}
|
||||
|
||||
if (out.subscription_level.name.empty()) {
|
||||
out.subscription_level.name = root.stringField("subscription_level");
|
||||
}
|
||||
if (out.subscription_level.id == 0) {
|
||||
out.subscription_level.id = static_cast<int>(root.numberField("subscription_level_id"));
|
||||
}
|
||||
if (out.subscription_level.description.empty()) {
|
||||
out.subscription_level.description = root.stringField("subscription_level_description");
|
||||
}
|
||||
// Any other fields (e.g. the legacy `subscription_level`) are ignored. A
|
||||
// successful validation itself is the "subscribed" flag; the kiosk treats
|
||||
// a 2xx response as an active license.
|
||||
|
||||
return !out.key.empty();
|
||||
}
|
||||
@@ -251,12 +233,12 @@ bool parseCreateAccountJson(const std::string& body, AccountBody& out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
AccountResult createAccount(const std::string& email, const std::string& subscription_level,
|
||||
const std::string& name, const std::string& apiKey) {
|
||||
AccountResult createAccount(const std::string& email, const std::string& name,
|
||||
const std::string& apiKey) {
|
||||
AccountResult result;
|
||||
|
||||
std::string jsonBody =
|
||||
"{\"email\":\"" + email + "\",\"subscription_level\":\"" + subscription_level + "\"";
|
||||
"{\"email\":\"" + email + "\"";
|
||||
if (!name.empty()) {
|
||||
jsonBody += ",\"name\":\"" + name + "\"";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user