Fixed compile errors

This commit is contained in:
WolverinDEV 2021-03-22 20:20:36 +01:00
parent 90fcc074f2
commit ea0f75756d
2 changed files with 32 additions and 53 deletions

View File

@ -97,7 +97,6 @@ namespace ts {
[[nodiscard]] inline std::shared_ptr<ts::event::EventExecutor> getConversationIo() { return this->conversation_io; }
[[nodiscard]] inline const auto& server_command_executor() { return this->server_command_executor_; }
[[nodiscard]] inline const auto& permission_helper() { return this->permission_helper_; }
[[nodiscard]] inline std::shared_ptr<license::LicenseService> license_service() { return this->license_service_; }
private:
@ -137,8 +136,6 @@ namespace ts {
std::shared_mutex default_tree_lock;
std::shared_ptr<ts::ServerChannelTree> default_tree = nullptr;
InstancePermissionHelper permission_helper_;
std::shared_ptr<groups::GroupManager> group_manager_{nullptr};
std::shared_ptr<ts::server::InternalClient> globalServerAdmin = nullptr;

View File

@ -22,6 +22,7 @@
#include "../../manager/ActionLogger.h"
#include "../../groups/GroupManager.h"
#include "../../absl/btree/map.h"
#include "../../PermissionCalculator.h"
#include <experimental/filesystem>
#include <cstdint>
#include <StringVariable.h>
@ -2825,14 +2826,9 @@ command_result ConnectedClient::handleCommandQueryList(ts::Command &cmd) {
if(!server && server_id != EmptyServerId && server_id != 0)
return command_result{error::server_invalid_id};
auto global_list = permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_list, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_list, this->getClientDatabaseId(), this->getType(), 0)
);
auto own_list = global_list || permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_list_own, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_list_own, this->getClientDatabaseId(), this->getType(), 0)
);
ClientPermissionCalculator client_permissions{server, this->getClientDatabaseId(), this->getType(), 0};
auto global_list = permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_list));
auto own_list = global_list || permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_list_own));
if(!own_list && !global_list)
return command_result{permission::b_client_query_list};
@ -2883,17 +2879,15 @@ command_result ConnectedClient::handleCommandQueryCreate(ts::Command &cmd) {
auto account = serverInstance->getQueryServer()->find_query_account_by_name(username);
if(account) return command_result{error::query_already_exists};
std::string uid = this->getUid();
ClientPermissionCalculator client_permissions{server, this->getClientDatabaseId(), this->getType(), 0};
auto uid{this->getUid()};
if(cmd[0].has("cldbid")){
if(!serverInstance->databaseHelper()->validClientDatabaseId(server, cmd["cldbid"].as<ClientDbId>()))
return command_result{error::database_empty_result};
if(server) {
if(!permission::v2::permission_granted(1, server->calculate_permission(permission::b_client_query_create, this->getClientDatabaseId(), this->getType(), 0)))
return command_result{permission::b_client_query_create};
} else {
if(!permission::v2::permission_granted(1, serverInstance->permission_helper().calculate_permission(permission::b_client_query_create, this->getClientDatabaseId(), this->getType(), 0)))
return command_result{permission::b_client_query_create};
if(!permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_create))) {
return command_result{permission::b_client_query_create};
}
auto info = serverInstance->databaseHelper()->queryDatabaseInfo(server, {cmd["cldbid"].as<ClientDbId>()});
@ -2901,12 +2895,8 @@ command_result ConnectedClient::handleCommandQueryCreate(ts::Command &cmd) {
return command_result{error::database_empty_result};
uid = info[0]->client_unique_id;
} else {
if(server) {
if(!permission::v2::permission_granted(1, server->calculate_permission(permission::b_client_query_create_own, this->getClientDatabaseId(), this->getType(), 0)))
return command_result{permission::b_client_query_create_own};
} else {
if(!permission::v2::permission_granted(1, serverInstance->permission_helper().calculate_permission(permission::b_client_query_create_own, this->getClientDatabaseId(), this->getType(), 0)))
return command_result{permission::b_client_query_create_own};
if(!permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_create_own))) {
return command_result{permission::b_client_query_create_own};
}
}
@ -2939,24 +2929,23 @@ command_result ConnectedClient::handleCommandQueryDelete(ts::Command &cmd) {
return command_result{error::server_invalid_id};
*/
auto delete_all = permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_delete, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_delete, this->getClientDatabaseId(), this->getType(), 0)
);
auto delete_own = delete_all || permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_delete_own, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_delete_own, this->getClientDatabaseId(), this->getType(), 0)
);
ClientPermissionCalculator client_permissions{server, this->getClientDatabaseId(), this->getType(), 0};
auto delete_all = permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_delete));
auto delete_own = delete_all || permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_delete_own));
if(account->unique_id == this->getUid()) {
if(!delete_own)
if(!delete_own) {
return command_result{permission::b_client_query_delete_own};
}
} else {
if(!delete_all)
if(!delete_all) {
return command_result{permission::b_client_query_delete};
}
}
if(account->unique_id == "serveradmin" && account->username == "serveradmin")
if(account->unique_id == "serveradmin" && account->username == "serveradmin") {
return command_result{error::vs_critical};
}
serverInstance->getQueryServer()->delete_query_account(account);
@ -2975,21 +2964,19 @@ command_result ConnectedClient::handleCommandQueryRename(ts::Command &cmd) {
if(!server && account->bound_server != 0)
return command_result{error::server_invalid_id};
auto rename_all = permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_rename, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_rename, this->getClientDatabaseId(), this->getType(), 0)
);
auto rename_own = rename_all || permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_rename_own, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_rename_own, this->getClientDatabaseId(), this->getType(), 0)
);
ClientPermissionCalculator client_permissions{server, this->getClientDatabaseId(), this->getType(), 0};
auto rename_all = permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_rename));
auto rename_own = rename_all || permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_rename_own));
if(account->unique_id == this->getUid()) {
if(!rename_own)
if(!rename_own) {
return command_result{permission::b_client_query_rename_own};
}
} else {
if(!rename_all)
if(!rename_all) {
return command_result{permission::b_client_query_rename};
}
}
auto target_account = serverInstance->getQueryServer()->find_query_account_by_name(new_username);
@ -3014,14 +3001,9 @@ command_result ConnectedClient::handleCommandQueryChangePassword(ts::Command &cm
if(!server && account->bound_server != 0)
return command_result{error::server_invalid_id};
auto change_all = permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_change_password, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_change_password_global, this->getClientDatabaseId(), this->getType(), 0)
);
auto change_own = change_all || permission::v2::permission_granted(1,
server ? server->calculate_permission(permission::b_client_query_change_own_password, this->getClientDatabaseId(), this->getType(), 0) :
serverInstance->permission_helper().calculate_permission(permission::b_client_query_change_own_password, this->getClientDatabaseId(), this->getType(), 0)
);
ClientPermissionCalculator client_permissions{server, this->getClientDatabaseId(), this->getType(), 0};
auto change_all = permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_change_password));
auto change_own = change_all || permission::v2::permission_granted(1, client_permissions.calculate_permission(permission::b_client_query_change_own_password));
auto password = cmd[0].has("client_login_password") ? cmd["client_login_password"].as<string>() : "";