|
Leosac
0.8.0
Open Source Access Control
|
Go to the documentation of this file.
29 #include "core/auth/UserGroupMembership_odb.h"
30 #include "core/auth/User_odb.h"
34 #include <nlohmann/json.hpp>
55 odb::transaction t(db->begin());
57 auto attributes = req.at(
"attributes");
58 auto gid = attributes.at(
"group_id").get<
size_t>();
59 auto uid = attributes.at(
"user_id").get<
size_t>();
69 if (group->member_has(user->id()))
72 <<
" is already in group "
76 auto membership = group->member_add(user, rank);
90 odb::transaction t(db->begin());
108 odb::transaction t(
ctx_.
dbsrv->db()->begin());
114 ctx_.
dbsrv->db(), membership->group().load(), membership->user().load(),
123 std::vector<CRUDResourceHandler::ActionActionParam>
125 const json &req)
const
127 using namespace JSONUtil;
129 std::vector<CRUDResourceHandler::ActionActionParam> ret;
virtual boost::optional< json > update_impl(const json &req) override
std::chrono::system_clock::time_point extract_with_default(const nlohmann::json &obj, const std::string &key, const std::chrono::system_clock::time_point &tp)
Extract an ISO 8601 datetime string from a json object.
#define BUILD_STR(param)
Internal macro.
std::unique_ptr< CRUDResourceHandler > CRUDResourceHandlerUPtr
@ GROUP_MEMBERSHIP_JOINED
Someone joined the group.
Base CRUD handler for use within the websocket module.
std::shared_ptr< odb::database > DBPtr
Auth::UserGroupMembershipId membership_id
All modules that provides features to Leosac shall be in this namespace.
@ GROUP_MEMBERSHIP_JOINED
This is the header file for a generated source file, GitSHA1.cpp.
unsigned long UserGroupMembershipId
A base class for Leosac specific exception.
virtual boost::optional< json > read_impl(const json &req) override
Retrieve information about a group.
static CRUDResourceHandlerUPtr instanciate(RequestContext)
virtual std::vector< ActionActionParam > required_permission(Verb verb, const json &req) const override
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
@ GROUP_MEMBERSHIP_LEFT
Someone left the group.
virtual boost::optional< json > create_impl(const json &req) override
Creating a new UserGroupMembersip: this means someone is joining a group.
Audit::IAuditEntryPtr audit
The initial audit trail for the request.
Holds valuable pointer to provide context to a request.
GroupRank
The rank of an User inside a Group.
MembershipCRUD(RequestContext ctx)
static json serialize(const Auth::UserGroupMembership &ugm, const SecurityContext &sc)
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.
virtual boost::optional< json > delete_impl(const json &req) override
static IUserGroupMembershipEventPtr UserGroupMembershipEvent(const DBPtr &database, Auth::GroupPtr target_group, Auth::UserPtr target_user, IAuditEntryPtr parent)