X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/bfc128f80e609e9578f36cf9ac9645cbd83a33d0..afcbfd1a09e22ff4839ba5db42047c96f355506c:/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp index 48ef3103..56167bc2 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp @@ -10,7 +10,6 @@ #include "users_methods.h" #include "rpcconfig.h" #include "user_helper.h" -#include "utils.h" //------------------------------------------------------------------------------ @@ -40,7 +39,7 @@ if (users->FindByName(login, &u)) return; } -USER_HELPER uhelper(u); +USER_HELPER uhelper(u, *users); if (!adminInfo.priviledges.userConf || !adminInfo.priviledges.userPasswd) { @@ -173,7 +172,7 @@ while (1) xmlrpc_c::value info; - USER_HELPER uhelper(u); + USER_HELPER uhelper(u, *users); uhelper.GetUserInfo(&info, hidePassword); @@ -217,7 +216,7 @@ if (users->FindByName(login, &u)) return; } -USER_HELPER uhelper(u); +USER_HELPER uhelper(u, *users); if (!adminInfo.priviledges.userConf || !adminInfo.priviledges.userPasswd) { @@ -382,16 +381,29 @@ if (tariffs->FindByName(tariff)) } else { - if (u->GetProperty().tariffName.Set(tariff, + const TARIFF * newTariff = tariffs->FindByName(tariff); + if (newTariff) + { + const TARIFF * currentTariff = u->GetTariff(); + std::string message = currentTariff->TariffChangeIsAllowed(*newTariff, stgTime); + if (message.empty()) + { + if (u->GetProperty().tariffName.Set(tariff, admin, login, store, comment)) - { - u->ResetNextTariff(); - u->WriteConf(); - *retvalPtr = xmlrpc_c::value_boolean(true); - return; + { + u->ResetNextTariff(); + u->WriteConf(); + *retvalPtr = xmlrpc_c::value_boolean(true); + return; + } + } + else + { + GetStgLogger()("Tariff change is prohibited for user %s. %s", u->GetLogin().c_str(), message.c_str()); + } } } } @@ -405,14 +417,13 @@ void METHOD_GET_ONLINE_IPS::execute(xmlrpc_c::paramList const & paramList, xmlrpc_c::value * const retvalPtr) { std::string cookie = paramList.getString(0); -std::vector subnetsStr = paramList.getArray(1); +typedef std::vector ValueVector; +ValueVector subnetsStr = paramList.getArray(1); paramList.verifyEnd(2); std::vector subnets; -std::vector::iterator it; - -for (it = subnetsStr.begin(); it != subnetsStr.end(); ++it) +for (ValueVector::const_iterator it(subnetsStr.begin()); it != subnetsStr.end(); ++it) { IP_MASK ipm; if (ParseNet(xmlrpc_c::value_string(*it), ipm)) @@ -435,7 +446,7 @@ if (config->GetAdminInfo(cookie, &adminInfo)) return; } -std::vector ips; +ValueVector ips; USER_PTR u; @@ -458,8 +469,7 @@ while (1) { uint32_t ip = u->GetCurrIP(); - std::vector::iterator it; - for (it = subnets.begin(); it != subnets.end(); ++it) + for (std::vector::const_iterator it(subnets.begin()); it != subnets.end(); ++it) { if ((it->ip & it->mask) == (ip & it->mask)) { @@ -512,3 +522,36 @@ ipm.mask = htonl(0xffFFffFF << (32 - ipm.mask)); return false; } + +void METHOD_GET_USER_AUTH_BY::execute(xmlrpc_c::paramList const & paramList, + xmlrpc_c::value * const retvalPtr) +{ +std::string cookie = paramList.getString(0); +std::string login = paramList.getString(1); +paramList.verifyEnd(2); + +std::map structVal; +ADMIN_INFO adminInfo; + +if (config->GetAdminInfo(cookie, &adminInfo)) + { + structVal["result"] = xmlrpc_c::value_boolean(false); + *retvalPtr = xmlrpc_c::value_struct(structVal); + return; + } + +USER_PTR u; + +if (users->FindByName(login, &u)) + { + structVal["result"] = xmlrpc_c::value_boolean(false); + *retvalPtr = xmlrpc_c::value_struct(structVal); + return; + } + +std::vector list(u->GetAuthorizers()); +std::vector authList; +for (std::vector::const_iterator it = list.begin(); it != list.end(); ++it) + authList.push_back(xmlrpc_c::value_string(*it)); +*retvalPtr = xmlrpc_c::value_array(authList); +}