X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/4f1aca7dfb6adf867713ad48e14ad79080e13cfa..da585bb94c437f06762a2042ef4c52166b8aafce:/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp index 89c41587..ac6e7261 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp @@ -433,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))