24 #include "core/auth/Group_odb.h" 39 return std::make_unique<GroupSearch>(ctx);
48 return g1.
id() < g2.
id();
54 json rep = json::array();
56 odb::transaction t(db->begin());
57 using Query = odb::query<Auth::Group>;
58 std::string partial_name = req.at(
"partial_name");
59 std::set<Auth::Group, GroupComparator> groups;
66 for (
auto i = 0u; i < partial_name.length(); ++i)
68 auto partial_name_copy = partial_name;
69 partial_name_copy[i] = std::toupper(partial_name[i]);
70 Query q(Query::name.like(
"%" + partial_name_copy +
"%"));
71 auto results = db->query(q);
72 for (
const auto &group : results)
78 Query q(Query::name.like(
"%" + partial_name +
"%"));
79 auto results = db->query(q);
80 for (
const auto &group : results)
85 for (
const auto &group : groups)
87 json result_json = {{
"id", group.id()}, {
"name", group.name()}};
88 rep.push_back(result_json);
96 std::vector<ActionActionParam> perm_;
GroupId id() const
Retrieve the unique identifier of the group.
The base class for API method handler implementation.
This is the header file for a generated source file, GitSHA1.cpp.
virtual json process_impl(const json &req) override
The API method implementation.
A authentication group regroup users that share permissions.
GroupSearch(RequestContext ctx)
std::unique_ptr< MethodHandler > MethodHandlerUPtr
bool operator()(const Auth::Group &g1, const Auth::Group &g2)
odb::query< Tools::LogEntry > Query
All modules that provides features to Leosac shall be in this namespace.
#define ASSERT_LOG(cond, msg)
std::vector< ActionActionParam > required_permission(const json &req) const override
Return a list of "Action" / "ActionParam" that must pass before the request is processed.
static MethodHandlerUPtr create(RequestContext)
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr