From: Maxim Mamontov <faust.madf@gmail.com>
Date: Fri, 26 Jul 2013 16:33:05 +0000 (+0300)
Subject: Added a function that lists all plugins that authorize the user.
X-Git-Tag: 2.409~357
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/40079f3d50a559ea36705b72b2fe2d190a6cc354?ds=sidebyside

Added a function that lists all plugins that authorize the user.
---

diff --git a/include/stg/user.h b/include/stg/user.h
index b9d638d6..0adb342a 100644
--- a/include/stg/user.h
+++ b/include/stg/user.h
@@ -24,6 +24,9 @@
 #include <ctime>
 #include <string>
 
+#include <vector>
+#include <string>
+
 #include "os_int.h"
 #include "notifer.h"
 #include "message.h"
@@ -77,6 +80,7 @@ public:
                                           const AUTH * auth) = 0;
     virtual void                Unauthorize(const AUTH * auth) = 0;*/
     virtual bool                IsAuthorizedBy(const AUTH * auth) const = 0;
+    virtual std::vector<std::string> GetAuthorizers() const = 0;
 
     virtual int                 AddMessage(STG_MSG * msg) = 0;
 
diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp
index ac8399ca..5bb0069f 100644
--- a/projects/stargazer/user_impl.cpp
+++ b/projects/stargazer/user_impl.cpp
@@ -38,6 +38,8 @@
 #include <cassert>
 #include <cstdlib>
 #include <cmath>
+#include <algorithm>
+#include <functional>
 
 #include "stg/users.h"
 #include "stg/common.h"
@@ -566,6 +568,13 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 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)
 {
 /*
diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h
index 5e8f49db..a581f2e5 100644
--- a/projects/stargazer/user_impl.h
+++ b/projects/stargazer/user_impl.h
@@ -29,6 +29,7 @@
 
 #include <ctime>
 #include <list>
+#include <vector>
 #include <string>
 #include <set>
 
@@ -186,6 +187,7 @@ public:
     int             Authorize(uint32_t ip, uint32_t enabledDirs, const AUTH * auth);
     void            Unauthorize(const AUTH * auth);
     bool            IsAuthorizedBy(const AUTH * auth) const;
+    std::vector<std::string> GetAuthorizers() const;
 
     int             AddMessage(STG_MSG * msg);