]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.cpp
Added stream encryption/decryption tests.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_auth_by.cpp
index e1da75b682f4c25f31e830578909ec1a02ca575b..21765e11c1a9b18dcf10181797145bd69c8e2eee 100644 (file)
@@ -1,5 +1,8 @@
 #include "parser_auth_by.h"
 
 #include "parser_auth_by.h"
 
+#include "stg/users.h"
+#include "stg/user.h"
+
 int PARSER_AUTH_BY::ParseStart(void * /*data*/, const char *el, const char **attr)
 {
 if (strcasecmp(el, "GetUserAuthBy") == 0)
 int PARSER_AUTH_BY::ParseStart(void * /*data*/, const char *el, const char **attr)
 {
 if (strcasecmp(el, "GetUserAuthBy") == 0)
@@ -28,19 +31,17 @@ return -1;
 
 void PARSER_AUTH_BY::CreateAnswer()
 {
 
 void PARSER_AUTH_BY::CreateAnswer()
 {
-answerList->erase(answerList->begin(), answerList->end());
-
 USER_PTR u;
 if (users->FindByName(login, &u))
     {
 USER_PTR u;
 if (users->FindByName(login, &u))
     {
-    answerList->push_back("<user result=\"error\"/>");
+    answer = "<AuthorizedBy result=\"error\" reason=\"User not found.\"/>";
     return;
     }
 
     return;
     }
 
-std::string s = "<AuthorizedBy>";
+answer.clear();
+answer += "<AuthorizedBy result=\"ok\">";
 std::vector<std::string> list(u->GetAuthorizers());
 for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
 std::vector<std::string> list(u->GetAuthorizers());
 for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
-    s += "<Auth name=\"" + *it + "\"/>";
-s += "</AuthorizedBy>";
-answerList->push_back(s);
+    answer += "<Auth name=\"" + *it + "\"/>";
+answer += "</AuthorizedBy>";
 }
 }