-UsersImpl::UsersImpl(SettingsImpl * s, Store * st,
- Tariffs * t, Services & svcs,
- const Admin& sa)
+UsersImpl::UsersImpl(SettingsImpl * s, Store * store,
+ Tariffs * tariffs, Services & svcs,
+ const Admin& sysAdmin)
WriteServLog(Logger::get()),
isRunning(false),
handle(0)
{
}
//-----------------------------------------------------------------------------
WriteServLog(Logger::get()),
isRunning(false),
handle(0)
{
}
//-----------------------------------------------------------------------------
-}
-//-----------------------------------------------------------------------------
-int UsersImpl::FindByNameNonLock(const std::string & login, user_iter * user)
-{
-const std::map<std::string, user_iter>::const_iterator iter(loginIndex.find(login));
+const auto iter = loginIndex.find(login);
}
//-----------------------------------------------------------------------------
int UsersImpl::FindByName(const std::string & login, UserPtr * user)
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter u;
}
//-----------------------------------------------------------------------------
int UsersImpl::FindByName(const std::string & login, UserPtr * user)
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter u;
return iter != loginIndex.end();
}
//-----------------------------------------------------------------------------
bool UsersImpl::TariffInUse(const std::string & tariffName) const
{
std::lock_guard<std::mutex> lock(m_mutex);
return iter != loginIndex.end();
}
//-----------------------------------------------------------------------------
bool UsersImpl::TariffInUse(const std::string & tariffName) const
{
std::lock_guard<std::mutex> lock(m_mutex);
{
WriteServLog("%s tried to add user \'%s\'. Access denied.",
admin->logStr().c_str(), login.c_str());
return -1;
}
{
WriteServLog("%s tried to add user \'%s\'. Access denied.",
admin->logStr().c_str(), login.c_str());
return -1;
}
-UserImpl u(settings, store, tariffs, &sysAdmin, this, m_services);
+UserImpl u(settings, m_store, m_tariffs, &m_sysAdmin, this, m_services);
{
WriteServLog("%s tried to remove user \'%s\'. Access denied.",
admin->logStr().c_str(), login.c_str());
{
WriteServLog("%s tried to remove user \'%s\'. Access denied.",
admin->logStr().c_str(), login.c_str());
{
WriteServLog("Attempt to unauthorize non-existant user '%s'", login.c_str());
printfd(__FILE__, "Attempt to unauthorize non-existant user '%s'", login.c_str());
{
WriteServLog("Attempt to unauthorize non-existant user '%s'", login.c_str());
printfd(__FILE__, "Attempt to unauthorize non-existant user '%s'", login.c_str());
- UserImpl u(settings, store, tariffs, &sysAdmin, this, m_services);
+ UserImpl u(settings, m_store, m_tariffs, &m_sysAdmin, this, m_services);
//-----------------------------------------------------------------------------
void UsersImpl::DayResetTraff(const struct tm & t1)
{
//-----------------------------------------------------------------------------
void UsersImpl::DayResetTraff(const struct tm & t1)
{
printfd(__FILE__, "Before USERS::Run()\n");
for_each(users.begin(), users.end(), [](auto& user){ user.Run(); });
printfd(__FILE__, "Before USERS::Run()\n");
for_each(users.begin(), users.end(), [](auto& user){ user.Run(); });
-// 'cause bind2st accepts only constant first param
-for (std::list<UserImpl>::iterator it = users.begin();
- it != users.end();
- ++it)
- it->WriteDetailStat(true);
+for (auto& user : users)
+ user.WriteDetailStat(true);
for_each(users.begin(), users.end(), [](auto& user){ user.WriteStat(); });
//for_each(users.begin(), users.end(), mem_fun_ref(&UserImpl::WriteConf));
for_each(users.begin(), users.end(), [](auto& user){ user.WriteStat(); });
//for_each(users.begin(), users.end(), mem_fun_ref(&UserImpl::WriteConf));
while (iter != usersToDelete.end())
{
printfd(__FILE__, "RealDelUser() user=%s\n", iter->iter->GetLogin().c_str());
if (iter->delTime + userDeleteDelayTime < stgTime)
{
printfd(__FILE__, "RealDelUser() user=%s removed from DB\n", iter->iter->GetLogin().c_str());
while (iter != usersToDelete.end())
{
printfd(__FILE__, "RealDelUser() user=%s\n", iter->iter->GetLogin().c_str());
if (iter->delTime + userDeleteDelayTime < stgTime)
{
printfd(__FILE__, "RealDelUser() user=%s removed from DB\n", iter->iter->GetLogin().c_str());
}
//-----------------------------------------------------------------------------
void UsersImpl::AddToIPIdx(user_iter user)
}
//-----------------------------------------------------------------------------
void UsersImpl::AddToIPIdx(user_iter user)
printfd(__FILE__, "USERS: Add IP Idx\n");
uint32_t ip = user->GetCurrIP();
//assert(ip && "User has non-null ip");
printfd(__FILE__, "USERS: Add IP Idx\n");
uint32_t ip = user->GetCurrIP();
//assert(ip && "User has non-null ip");
//-----------------------------------------------------------------------------
bool UsersImpl::FindByIPIdx(uint32_t ip, user_iter & iter) const
{
//-----------------------------------------------------------------------------
bool UsersImpl::FindByIPIdx(uint32_t ip, user_iter & iter) const
{
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
{
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
{
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
{
{
std::lock_guard<std::mutex> lock(m_mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
{
}
//-----------------------------------------------------------------------------
bool UsersImpl::IsIPInUse(uint32_t ip, const std::string & login, ConstUserPtr * user) const
{
std::lock_guard<std::mutex> lock(m_mutex);
}
//-----------------------------------------------------------------------------
bool UsersImpl::IsIPInUse(uint32_t ip, const std::string & login, ConstUserPtr * user) const
{
std::lock_guard<std::mutex> lock(m_mutex);
while (iter != users.end())
{
if (iter->GetLogin() != login &&
!iter->GetProperties().ips.Get().isAnyIP() &&
iter->GetProperties().ips.Get().find(ip))
{
while (iter != users.end())
{
if (iter->GetLogin() != login &&
!iter->GetProperties().ips.Get().isAnyIP() &&
iter->GetProperties().ips.Get().find(ip))
{
onDelNotifiersImpl.erase(n);
}
//-----------------------------------------------------------------------------
onDelNotifiersImpl.erase(n);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int UsersImpl::SearchNext(int h, UserPtr * user)
{
//-----------------------------------------------------------------------------
int UsersImpl::SearchNext(int h, UserPtr * user)
{
//-----------------------------------------------------------------------------
bool UsersImpl::TimeToWriteDetailStat(const struct tm & t)
{
//-----------------------------------------------------------------------------
bool UsersImpl::TimeToWriteDetailStat(const struct tm & t)
{