X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/e9cb0683c0b33d8458c1d9b2558bbeb5d101e680..d8845c7819caac09b95c4cdf1e8d48cc1cb1b7a6:/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp?ds=sidebyside diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp index 5adbf441..56167bc2 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp @@ -381,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()); + } } } }