|
@@ -402,11 +402,20 @@ JsonCommander::Response JsonCommander::checkLogin(const Json::Value &message) {
|
|
|
response.json["accept"] = true;
|
|
|
response.json["error"] = "";
|
|
|
} else if (!message["login"].asBool()) {
|
|
|
- // TODO implement registration
|
|
|
- response.action = closeAndSend;
|
|
|
- response.json["accept"] = false;
|
|
|
- response.json["error"] = "registration is not yet implemented";
|
|
|
+ // add user. Check if already exists before
|
|
|
+ if (!UserManager::addUser(message["user"].asString(),
|
|
|
+ message["pass"].asString())) {
|
|
|
+ response.action = closeAndSend;
|
|
|
+ response.json["accept"] = false;
|
|
|
+ response.json["error"] = "user does already exist";
|
|
|
+ } else {
|
|
|
+ response.action = send;
|
|
|
+ response.json["accept"] = true;
|
|
|
+ response.json["error"] = "";
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
+ // reject user
|
|
|
response.action = closeAndSend;
|
|
|
response.json["accept"] = false;
|
|
|
response.json["error"] = "wrong username or password";
|