#include <cassert>
#include <cstdlib>
#include <cmath>
+#include <algorithm>
+#include <functional>
#include "stg/users.h"
#include "stg/common.h"
return 0;
}
//-----------------------------------------------------------------------------
-void USER_IMPL::Unauthorize(const AUTH * auth)
+void USER_IMPL::Unauthorize(const AUTH * auth, const std::string & reason)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
/*
if (authorizedBy.empty())
{
+ lastDisconnectReason = reason;
lastIPForDisconnect = currIP;
currIP = 0; // DelUser in traffcounter
return;
return authorizedBy.find(auth) != authorizedBy.end();
}
//-----------------------------------------------------------------------------
+std::vector<std::string> USER_IMPL::GetAuthorizers() const
+{
+ std::vector<std::string> list;
+ std::transform(authorizedBy.begin(), authorizedBy.end(), std::back_inserter(list), std::mem_fun(&AUTH::GetVersion));
+ return list;
+}
+//-----------------------------------------------------------------------------
void USER_IMPL::Connect(bool fakeConnect)
{
/*
connected = false;
}
-if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload, cash, freeMb, reason))
+std::string reasonMessage(reason);
+if (!lastDisconnectReason.empty())
+ reasonMessage += ": " + lastDisconnectReason;
+
+if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload,
+ cash, freeMb, reasonMessage))
{
WriteServLog("Cannot write disconnect for user %s.", login.c_str());
WriteServLog("%s", store->GetStrError().c_str());