]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Add cstdlib header to user_impl.cpp (use random() function)
[stg.git] / projects / stargazer / user_impl.cpp
index f18dd76e98dd87be55fe0a74559867e255639aab..eace1afb41e433d4caa6c99a73a272830cf32260 100644 (file)
@@ -36,6 +36,7 @@
 #include <unistd.h> // access
 
 #include <cassert>
+#include <cstdlib>
 
 #include "user_impl.h"
 #include "users.h"
 #include "admin.h"
 
 USER_IMPL::USER_IMPL(const SETTINGS * s,
-           const BASE_STORE * st,
+           const STORE * st,
            const TARIFFS * t,
-           const ADMIN & a,
+           const ADMIN * a,
            const USERS * u)
     : users(u),
-      property(s),
+      property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       login(),
       id(0),
@@ -132,7 +133,7 @@ pthread_mutex_init(&mutex, &attr);
 //-----------------------------------------------------------------------------
 USER_IMPL::USER_IMPL(const USER_IMPL & u)
     : users(u.users),
-      property(u.settings),
+      property(u.settings->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       login(u.login),
       id(u.id),
@@ -351,7 +352,7 @@ if (store->SaveMonthStat(stat, t1.tm_mon, t1.tm_year, login))
 return 0;
 }
 //-----------------------------------------------------------------------------
-int USER_IMPL::Authorize(uint32_t ip, const string &, uint32_t dirs, const BASE_AUTH * auth)
+int USER_IMPL::Authorize(uint32_t ip, uint32_t dirs, const AUTH * auth)
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 /*
@@ -424,7 +425,7 @@ ScanMessage();
 return 0;
 }
 //-----------------------------------------------------------------------------
-void USER_IMPL::Unauthorize(const BASE_AUTH * auth)
+void USER_IMPL::Unauthorize(const AUTH * auth)
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 /*
@@ -441,7 +442,7 @@ if (authorizedBy.empty())
     }
 }
 //-----------------------------------------------------------------------------
-bool USER_IMPL::IsAuthorizedBy(const BASE_AUTH * auth) const
+bool USER_IMPL::IsAuthorizedBy(const AUTH * auth) const
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 //  Is this user authorized by specified authorizer?
@@ -458,7 +459,7 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 
 if (!fakeConnect)
     {
-    string scriptOnConnect = settings->GetScriptDir() + "/OnConnect";
+    string scriptOnConnect = settings->GetScriptsDir() + "/OnConnect";
 
     if (access(scriptOnConnect.c_str(), X_OK) == 0)
         {
@@ -515,7 +516,7 @@ if (!lastIPForDisconnect)
 
 if (!fakeDisconnect)
     {
-    string scriptOnDisonnect = settings->GetScriptDir() + "/OnDisconnect";
+    string scriptOnDisonnect = settings->GetScriptsDir() + "/OnDisconnect";
 
     if (access(scriptOnDisonnect.c_str(), X_OK) == 0)
         {
@@ -911,7 +912,7 @@ void USER_IMPL::OnAdd()
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 
-string scriptOnAdd = settings->GetScriptDir() + "/OnUserAdd";
+string scriptOnAdd = settings->GetScriptsDir() + "/OnUserAdd";
 
 if (access(scriptOnAdd.c_str(), X_OK) == 0)
     {
@@ -933,7 +934,7 @@ void USER_IMPL::OnDelete()
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 
-string scriptOnDel = settings->GetScriptDir() + "/OnUserDel";
+string scriptOnDel = settings->GetScriptsDir() + "/OnUserDel";
 
 if (access(scriptOnDel.c_str(), X_OK) == 0)
     {
@@ -1190,7 +1191,7 @@ int USER_IMPL::SendMessage(STG_MSG & msg) const
 {
 // No lock `cause we are already locked from caller
 int ret = -1;
-set<const BASE_AUTH*>::iterator it(authorizedBy.begin());
+set<const AUTH*>::iterator it(authorizedBy.begin());
 while (it != authorizedBy.end())
     {
     if (!(*it++)->SendMessage(msg, currIP))