X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1347f3d1e04bedd1508589173f577673ee2c5554..da585bb94c437f06762a2042ef4c52166b8aafce:/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp?ds=inline diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp index 665a04f4..ac6e7261 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp @@ -161,6 +161,18 @@ if ((it = structVal.find("ips")) != structVal.end()) { USER_IPS ips; ips = StrToIPS(xmlrpc_c::value_string(it->second)); + + for (size_t i = 0; i < ips.Count(); ++i) + { + CONST_USER_PTR user; + uint32_t ip = ips[i].ip; + if (users.IsIPInUse(ip, login, &user)) + { + printfd(__FILE__, "Trying to assign an IP %s to '%s' that is already in use by '%s'\n", inet_ntostring(ip).c_str(), login.c_str(), user->GetLogin().c_str()); + return true; + } + } + if (!ptr->GetProperty().ips.Set(ips, admin, login, @@ -421,13 +433,27 @@ if ((it = structVal.find("tariff")) != structVal.end()) tariff = tariff.substr(0, pos); } - if (tariffs->FindByName(tariff)) - if (ptr->GetProperty().tariffName.Get() != tariff) - if (!ptr->GetProperty().tariffName.Set(tariff, - admin, - login, - &store)) - return true; + const TARIFF * newTariff = tariffs->FindByName(tariff); + if (newTariff) + { + const TARIFF * currentTariff = ptr->GetTariff(); + std::string message = currentTariff->TariffChangeIsAllowed(*newTariff, stgTime); + if (message.empty()) + { + if (ptr->GetProperty().tariffName.Get() != tariff) + { + if (!ptr->GetProperty().tariffName.Set(tariff, + admin, + login, + &store)) + return true; + } + } + else + { + GetStgLogger()("Tariff change is prohibited for user %s. %s", ptr->GetLogin().c_str(), message.c_str()); + } + } if (nextTariff != "" && tariffs->FindByName(nextTariff))