]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Ticket 37. In the ProcessNewMonth() function switch construction changed
[stg.git] / projects / stargazer / user_impl.cpp
index e832c669950f4088d56b6fb0d3ae25ff7da26655..72a3378f771876873f39aab1caf8ea408efde56b 100644 (file)
@@ -77,7 +77,8 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
            const STORE * st,
            const TARIFFS * t,
            const ADMIN * a,
-           const USERS * u)
+           const USERS * u,
+           const SERVICES & svcs)
     : users(u),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
@@ -93,6 +94,7 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
       store(st),
       tariffs(t),
       tariff(NULL),
+      m_services(svcs),
       settings(s),
       authorizedModificationTime(0),
       deleted(false),
@@ -145,7 +147,8 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
                      const STORE * st,
                      const TARIFFS * t,
                      const ADMIN * a,
-                     const USERS * u)
+                     const USERS * u,
+                     const SERVICES & svcs)
     : users(u),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
@@ -161,6 +164,7 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
       store(st),
       tariffs(t),
       tariff(NULL),
+      m_services(svcs),
       settings(s),
       authorizedModificationTime(0),
       deleted(false),
@@ -249,6 +253,7 @@ USER_IMPL::USER_IMPL(const USER_IMPL & u)
       store(u.store),
       tariffs(u.tariffs),
       tariff(u.tariff),
+      m_services(u.m_services),
       traffStat(u.traffStat),
       traffStatSaved(u.traffStatSaved),
       settings(u.settings),
@@ -552,6 +557,8 @@ if (authorizedBy.empty())
     lastDisconnectReason = reason;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
+    if (connected)
+        Disconnect(false, "not authorized");
     return;
     }
 }
@@ -1171,10 +1178,24 @@ if (nextTariff.ConstData() != "")
     {
     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());
+        }
     else
-        property.tariffName.Set(nextTariff, sysAdmin, login, store);
+        {
+        if (tariff->TariffChangelsAllowed(*nt) == "")
+            {
+            property.tariffName.Set(nextTariff, sysAdmin, login, store);
+            }
+        else
+            {
+            std::string message = tariff->TariffChangelsAllowed(*nt);
+            WriteServLog("Tariff change is prohibited for user %s. %s",
+                         login.c_str(),
+                         message.c_str());
+            }
+        }
     ResetNextTariff();
     WriteConf();
     }