]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Ticket 37. TariffChangelsAllowed function name changed to
[stg.git] / projects / stargazer / user_impl.cpp
index 3693057692592f549084729b6769b588018f8211..7701bde3fa3b8bf09b463223c2f7ac306ca259ef 100644 (file)
@@ -557,6 +557,8 @@ if (authorizedBy.empty())
     lastDisconnectReason = reason;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
     lastDisconnectReason = reason;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
+    if (connected)
+        Disconnect(false, "not authorized");
     return;
     }
 }
     return;
     }
 }
@@ -1176,10 +1178,24 @@ if (nextTariff.ConstData() != "")
     {
     const TARIFF * nt = tariffs->FindByName(nextTariff);
     if (nt == NULL)
     {
     const TARIFF * nt = tariffs->FindByName(nextTariff);
     if (nt == NULL)
+        {
         WriteServLog("Cannot change tariff for user %s. Tariff %s not exist.",
                      login.c_str(), property.tariffName.Get().c_str());
         WriteServLog("Cannot change tariff for user %s. Tariff %s not exist.",
                      login.c_str(), property.tariffName.Get().c_str());
+        }
     else
     else
-        property.tariffName.Set(nextTariff, sysAdmin, login, store);
+        {
+        if (tariff->TariffChangeIsAllowed(*nt) == "")
+            {
+            property.tariffName.Set(nextTariff, sysAdmin, login, store);
+            }
+        else
+            {
+            std::string message = tariff->TariffChangeIsAllowed(*nt);
+            WriteServLog("Tariff change is prohibited for user %s. %s",
+                         login.c_str(),
+                         message.c_str());
+            }
+        }
     ResetNextTariff();
     WriteConf();
     }
     ResetNextTariff();
     WriteConf();
     }