Using new permissions system consequently
This commit is contained in:
@@ -881,4 +881,37 @@ void InstanceHandler::loadWebCertificate() {
|
||||
|
||||
this->sslMgr->rename_context(strobf("web_default_new").string(), strobf("web_default").string());
|
||||
this->web_cert_revision = revision;
|
||||
}
|
||||
|
||||
|
||||
permission::v2::PermissionFlaggedValue InstanceHandler::calculate_permission(permission::PermissionType permission,
|
||||
ClientDbId cldbid, ClientType type, ChannelId channel, bool granted, std::shared_ptr<CalculateCache> cache) {
|
||||
auto result = this->calculate_permissions({permission}, cldbid, type, channel, granted, cache);
|
||||
if(result.empty()) return {0, false};
|
||||
return result.front().second;
|
||||
}
|
||||
|
||||
std::vector<std::pair<permission::PermissionType, permission::v2::PermissionFlaggedValue> > InstanceHandler::calculate_permissions(
|
||||
const std::deque<permission::PermissionType> &permissions, ClientDbId cldbid, ClientType type, ChannelId channel, bool granted, std::shared_ptr<CalculateCache> cache) {
|
||||
std::vector<std::pair<permission::PermissionType, permission::v2::PermissionFlaggedValue>> result{};
|
||||
|
||||
//TODO: Negate?
|
||||
//TODO: May move this part to the instance?
|
||||
|
||||
auto server_groups = this->getGroupManager()->getServerGroups(cldbid, type);
|
||||
for(const auto& permission : permissions) {
|
||||
permission::v2::PermissionFlaggedValue value{0, false};
|
||||
|
||||
for(const auto &gr : this->getGroupManager()->getServerGroups(cldbid, type)){
|
||||
auto group_permissions = gr->group->permissions();
|
||||
auto flagged_permissions = granted ? group_permissions->permission_granted_flagged(permission) : group_permissions->permission_value_flagged(permission);
|
||||
if(flagged_permissions.has_value)
|
||||
if(!value.has_value || flagged_permissions.value > value.value || flagged_permissions.value == -1)
|
||||
value = flagged_permissions;
|
||||
}
|
||||
|
||||
result.emplace_back(permission, value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user