]> git.stg.codes - stg.git/commitdiff
Added a function that lists all plugins that authorize the user.
authorMaxim Mamontov <faust.madf@gmail.com>
Fri, 26 Jul 2013 16:33:05 +0000 (19:33 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Fri, 26 Jul 2013 16:33:05 +0000 (19:33 +0300)
include/stg/user.h
projects/stargazer/user_impl.cpp
projects/stargazer/user_impl.h

index b9d638d626a5437a0ebc8c1b49d501c7ba43781b..0adb342ae9261841017370c169398e22449f981a 100644 (file)
@@ -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;
 
index ac8399cabe77cf7149267dcdc71562eab1ac7563..5bb0069fb6f04b79a476001e135d09ddd7a3176d 100644 (file)
@@ -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)
 {
 /*
index 5e8f49dbad303a53d95607d4776c1bbe73f83c70..a581f2e55c48f586d98017e69c016e36ba7b8b2c 100644 (file)
@@ -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);