1 #include "parser_auth_by.h"
3 int PARSER_AUTH_BY::ParseStart(void * /*data*/, const char *el, const char **attr)
5 if (strcasecmp(el, "GetUserAuthBy") == 0)
7 if (attr[0] && attr[1])
11 login.erase(login.begin(), login.end());
19 int PARSER_AUTH_BY::ParseEnd(void * /*data*/, const char *el)
21 if (strcasecmp(el, "GetUserAuthBy") == 0)
29 void PARSER_AUTH_BY::CreateAnswer()
31 answerList->erase(answerList->begin(), answerList->end());
34 if (users->FindByName(login, &u))
36 answerList->push_back("<AuthorizedBy result=\"error\" reason=\"User not found.\"/>");
40 std::string s = "<AuthorizedBy result=\"ok\">";
41 std::vector<std::string> list(u->GetAuthorizers());
42 for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
43 s += "<Auth name=\"" + *it + "\"/>";
44 s += "</AuthorizedBy>";
45 answerList->push_back(s);