mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:24:24 +02:00
cleanup handling of defaults for standard user perms
This commit is contained in:
parent
f8ea180127
commit
cd436355fc
1 changed files with 19 additions and 34 deletions
|
@ -469,23 +469,11 @@ bool DomainServerSettingsManager::unpackPermissionsForKeypath(const QString& key
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServerSettingsManager::unpackPermissions() {
|
void DomainServerSettingsManager::unpackPermissions() {
|
||||||
// transfer details from _configMap to _agentPermissions;
|
// transfer details from _configMap to _agentPermissions
|
||||||
|
|
||||||
bool foundLocalhost = false;
|
|
||||||
bool foundAnonymous = false;
|
|
||||||
bool foundLoggedIn = false;
|
|
||||||
bool foundFriends = false;
|
|
||||||
|
|
||||||
bool needPack = false;
|
bool needPack = false;
|
||||||
|
|
||||||
needPack |= unpackPermissionsForKeypath(AGENT_STANDARD_PERMISSIONS_KEYPATH, &_standardAgentPermissions,
|
needPack |= unpackPermissionsForKeypath(AGENT_STANDARD_PERMISSIONS_KEYPATH, &_standardAgentPermissions);
|
||||||
[&foundLocalhost, &foundAnonymous, &foundLoggedIn, &foundFriends](NodePermissionsPointer perms){
|
|
||||||
NodePermissionsKey idKey = perms->getKey();
|
|
||||||
foundLocalhost |= (idKey == NodePermissions::standardNameLocalhost);
|
|
||||||
foundAnonymous |= (idKey == NodePermissions::standardNameAnonymous);
|
|
||||||
foundLoggedIn |= (idKey == NodePermissions::standardNameLoggedIn);
|
|
||||||
foundFriends |= (idKey == NodePermissions::standardNameFriends);
|
|
||||||
});
|
|
||||||
|
|
||||||
needPack |= unpackPermissionsForKeypath(AGENT_PERMISSIONS_KEYPATH, &_agentPermissions);
|
needPack |= unpackPermissionsForKeypath(AGENT_PERMISSIONS_KEYPATH, &_agentPermissions);
|
||||||
needPack |= unpackPermissionsForKeypath(IP_PERMISSIONS_KEYPATH, &_ipPermissions);
|
needPack |= unpackPermissionsForKeypath(IP_PERMISSIONS_KEYPATH, &_ipPermissions);
|
||||||
|
@ -510,26 +498,23 @@ void DomainServerSettingsManager::unpackPermissions() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// if any of the standard names are missing, add them
|
// if any of the standard names are missing, add them
|
||||||
if (!foundLocalhost) {
|
foreach(const QString& standardName, NodePermissions::standardNames) {
|
||||||
NodePermissionsPointer perms { new NodePermissions(NodePermissions::standardNameLocalhost) };
|
NodePermissionsKey standardKey { standardName, 0 };
|
||||||
perms->setAll(true);
|
if (!_standardAgentPermissions.contains(standardKey)) {
|
||||||
_standardAgentPermissions[perms->getKey()] = perms;
|
// we don't have permissions for one of the standard groups, so we'll add them now
|
||||||
needPack = true;
|
NodePermissionsPointer perms { new NodePermissions(standardKey) };
|
||||||
}
|
|
||||||
if (!foundAnonymous) {
|
// the localhost user is granted all permissions by default
|
||||||
NodePermissionsPointer perms { new NodePermissions(NodePermissions::standardNameAnonymous) };
|
if (standardKey == NodePermissions::standardNameLocalhost) {
|
||||||
_standardAgentPermissions[perms->getKey()] = perms;
|
perms->setAll(true);
|
||||||
needPack = true;
|
}
|
||||||
}
|
|
||||||
if (!foundLoggedIn) {
|
// add the permissions to the standard map
|
||||||
NodePermissionsPointer perms { new NodePermissions(NodePermissions::standardNameLoggedIn) };
|
_standardAgentPermissions[standardKey] = perms;
|
||||||
_standardAgentPermissions[perms->getKey()] = perms;
|
|
||||||
needPack = true;
|
// this will require a packing of permissions
|
||||||
}
|
needPack = true;
|
||||||
if (!foundFriends) {
|
}
|
||||||
NodePermissionsPointer perms { new NodePermissions(NodePermissions::standardNameFriends) };
|
|
||||||
_standardAgentPermissions[perms->getKey()] = perms;
|
|
||||||
needPack = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
needPack |= ensurePermissionsForGroupRanks();
|
needPack |= ensurePermissionsForGroupRanks();
|
||||||
|
|
Loading…
Reference in a new issue