Fixed permissions

This commit is contained in:
WolverinDEV 2021-04-28 18:43:30 +02:00
parent cdf8aa1d69
commit 7753c95906
4 changed files with 11 additions and 11 deletions

View File

@ -83,13 +83,13 @@ command_result ConnectedClient::handleCommandClientKick(Command &cmd) {
}
if(type == ViewReasonId::VREASON_CHANNEL_KICK) {
auto kick_power = this->calculate_permission(permission::i_client_kick_from_channel_power, client->getChannelId());
auto kick_power = this->calculate_permission(permission::i_client_kick_from_channel_power, client->getChannelId()).zero_if_unset();
if(!permission::v2::permission_granted(client->calculate_permission(permission::i_client_needed_kick_from_channel_power, client->getChannelId()), kick_power)) {
result.emplace_result(permission::i_client_needed_kick_from_channel_power);
continue;
}
} else {
auto kick_power = this->calculate_permission(permission::i_client_kick_from_server_power, client->getChannelId());
auto kick_power = this->calculate_permission(permission::i_client_kick_from_server_power, client->getChannelId()).zero_if_unset();
if(!permission::v2::permission_granted(client->calculate_permission(permission::i_client_needed_kick_from_server_power, client->getChannelId()), kick_power)) {
result.emplace_result(permission::i_client_needed_kick_from_server_power);
continue;
@ -221,11 +221,11 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
}
if(target_client.client != this) {
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_client->getChannelId()), this->calculate_permission(permission::i_client_move_power, target_client->getChannelId()))) {
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_client->getChannelId()).zero_if_unset(), this->calculate_permission(permission::i_client_move_power, target_client->getChannelId()))) {
result.emplace_result(permission::i_client_move_power);
continue;
}
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_channel->channelId()), this->calculate_permission(permission::i_client_move_power, target_channel->channelId()))) {
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_channel->channelId()).zero_if_unset(), this->calculate_permission(permission::i_client_move_power, target_channel->channelId()))) {
result.emplace_result(permission::i_client_move_power);
continue;
}

View File

@ -489,7 +489,8 @@ command_result ConnectedClient::handleCommandSetClientChannelGroup(Command &cmd)
auto client_permission_modify_power = this->calculate_permission(permission::i_client_permission_modify_power, channel_id);
auto client_needed_permission_modify_power = this->server->calculate_permission(
permission::i_client_needed_permission_modify_power, target_cldbid, ClientType::CLIENT_TEAMSPEAK, channel_id);
permission::i_client_needed_permission_modify_power, target_cldbid, ClientType::CLIENT_TEAMSPEAK, channel_id
).zero_if_unset();
if(client_needed_permission_modify_power.has_value) {
@ -908,7 +909,7 @@ command_result ConnectedClient::handleCommandBanClient(Command &cmd) {
if(!target_database_id)
target_database_id = target_clients.back()->getClientDatabaseId();
}
if(!permission::v2::permission_granted(this->server->calculate_permission(permission::i_client_needed_ban_power, target_database_id, ClientType::CLIENT_TEAMSPEAK, 0), this->calculate_permission(permission::i_client_ban_power, 0)))
if(!permission::v2::permission_granted(this->server->calculate_permission(permission::i_client_needed_ban_power, target_database_id, ClientType::CLIENT_TEAMSPEAK, 0).zero_if_unset(), this->calculate_permission(permission::i_client_ban_power, 0)))
return command_result{permission::i_client_ban_power};
if (permission::v2::permission_granted(1, this->server->calculate_permission(permission::b_client_ignore_bans, target_database_id, ClientType::CLIENT_TEAMSPEAK, 0)))

View File

@ -403,7 +403,7 @@ command_result ConnectedClient::handleCommandServerGroupAddClient(Command &cmd)
}
ClientPermissionCalculator client_permissions{target_server, target_cldbid, ClientType::CLIENT_TEAMSPEAK, 0};
if(!permission::v2::permission_granted(client_permissions.calculate_permission(permission::i_client_needed_permission_modify_power), this->calculate_permission(permission::i_client_permission_modify_power, 0))) {
if(!permission::v2::permission_granted(client_permissions.calculate_permission(permission::i_client_needed_permission_modify_power).zero_if_unset(), this->calculate_permission(permission::i_client_permission_modify_power, 0))) {
return command_result{permission::i_client_needed_permission_modify_power};
}
@ -527,7 +527,7 @@ command_result ConnectedClient::handleCommandServerGroupDelClient(Command &cmd)
}
ClientPermissionCalculator client_permissions{target_server, target_cldbid, ClientType::CLIENT_TEAMSPEAK, 0};
if(!permission::v2::permission_granted(client_permissions.calculate_permission(permission::i_client_needed_permission_modify_power), this->calculate_permission(permission::i_client_permission_modify_power, 0))) {
if(!permission::v2::permission_granted(client_permissions.calculate_permission(permission::i_client_needed_permission_modify_power).zero_if_unset(), this->calculate_permission(permission::i_client_permission_modify_power, 0))) {
return command_result{permission::i_client_needed_permission_modify_power};
}

View File

@ -34,9 +34,8 @@ permission::PermissionType PlaylistPermissions::client_has_permissions(
if((flags & do_no_require_granted) == 0) {
playlist_permission.clear_flag_on_zero();
} else if(!playlist_permission.has_value) {
playlist_permission.value = 0;
playlist_permission.has_value = true;
} else {
playlist_permission.zero_if_unset();
}
return permission::v2::permission_granted(playlist_permission, client_permission) ? permission::ok : granted_permission;