From: Maxim Mamontov <faust.madf@gmail.com>
Date: Thu, 29 May 2014 14:49:48 +0000 (+0300)
Subject: Implemented check-user.
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/ef5fa0787eabd20beef3110c2fe55955d472ddc9?ds=inline

Implemented check-user.
---

diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp
index 9c6c30b5..680625c2 100644
--- a/projects/sgconf/users.cpp
+++ b/projects/sgconf/users.cpp
@@ -205,9 +205,14 @@ bool CheckUserFunction(const SGCONF::CONFIG & config,
                        const std::string & arg,
                        const std::map<std::string, std::string> & options)
 {
-// TODO
-std::cerr << "Unimplemented.\n";
-return false;
+std::map<std::string, std::string>::const_iterator it(options.find("password"));
+if (it == options.end())
+    throw SGCONF::ACTION::ERROR("Password is not specified.");
+STG::SERVCONF proto(config.server.data(),
+                    config.port.data(),
+                    config.userName.data(),
+                    config.userPass.data());
+return proto.CheckUser(arg, it->second, SimpleCallback, NULL) == STG::st_ok;
 }
 
 bool SendMessageFunction(const SGCONF::CONFIG & config,