|
@@ -11,6 +11,7 @@ JsonCommander::JsonCommander(FileManager &fileManager)
|
|
commandsMap["putdata"] = &JsonCommander::executePutdata;
|
|
commandsMap["putdata"] = &JsonCommander::executePutdata;
|
|
commandsMap["get"] = &JsonCommander::executeGet;
|
|
commandsMap["get"] = &JsonCommander::executeGet;
|
|
commandsMap["getdata"] = &JsonCommander::executeGetdata;
|
|
commandsMap["getdata"] = &JsonCommander::executeGetdata;
|
|
|
|
+ commandsMap["deleteme"] = &JsonCommander::executeDeleteMe;
|
|
}
|
|
}
|
|
|
|
|
|
JsonCommander::~JsonCommander() {}
|
|
JsonCommander::~JsonCommander() {}
|
|
@@ -310,6 +311,29 @@ JsonCommander::executeGetdata(const Json::Value &message) {
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+JsonCommander::Response
|
|
|
|
+JsonCommander::executeDeleteMe(const Json::Value &message) {
|
|
|
|
+ JsonCommander::Response response;
|
|
|
|
+ response.json["command"] = "deleteme";
|
|
|
|
+
|
|
|
|
+ if (!message["pass"].isString()) {
|
|
|
|
+ response.action = send;
|
|
|
|
+ response.json["accept"] = false;
|
|
|
|
+ response.json["error"] = "incorrect deleteme command request";
|
|
|
|
+ } else if (UserManager::deleteUser(currentUser, message["pass"].asString())) {
|
|
|
|
+ // success
|
|
|
|
+ response.action = closeAndSend;
|
|
|
|
+ response.json["accept"] = true;
|
|
|
|
+ response.json["error"] = "";
|
|
|
|
+ } else {
|
|
|
|
+ response.action = send;
|
|
|
|
+ response.json["accept"] = false;
|
|
|
|
+ response.json["error"] = "wrong password";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return response;
|
|
|
|
+}
|
|
|
|
+
|
|
JsonCommander::Response JsonCommander::testVersion(const Json::Value &message) {
|
|
JsonCommander::Response JsonCommander::testVersion(const Json::Value &message) {
|
|
JsonCommander::Response response;
|
|
JsonCommander::Response response;
|
|
response.json["version"] = this->protocolVersion;
|
|
response.json["version"] = this->protocolVersion;
|
|
@@ -345,11 +369,13 @@ JsonCommander::Response JsonCommander::checkLogin(const Json::Value &message) {
|
|
response.action = send;
|
|
response.action = send;
|
|
response.json["accept"] = true;
|
|
response.json["accept"] = true;
|
|
response.json["error"] = "";
|
|
response.json["error"] = "";
|
|
|
|
+ currentUser = message["user"].asString();
|
|
} else if (!message["login"].asBool()) {
|
|
} else if (!message["login"].asBool()) {
|
|
// TODO implement registration
|
|
// TODO implement registration
|
|
response.action = closeAndSend;
|
|
response.action = closeAndSend;
|
|
response.json["accept"] = false;
|
|
response.json["accept"] = false;
|
|
response.json["error"] = "registration is not yet implemented";
|
|
response.json["error"] = "registration is not yet implemented";
|
|
|
|
+ currentUser = message["user"].asString();
|
|
} else {
|
|
} else {
|
|
response.action = closeAndSend;
|
|
response.action = closeAndSend;
|
|
response.json["accept"] = false;
|
|
response.json["accept"] = false;
|