hook into ACL system for CM shenanigans

This commit is contained in:
in1tiate 2021-03-02 20:45:01 -06:00
parent 6a6029b6da
commit 0b024abe5c
3 changed files with 21 additions and 38 deletions

View File

@ -63,6 +63,7 @@ class AOClient : public QObject {
{"BAN", 1ULL << 1},
{"BGLOCK", 1ULL << 2},
{"MODIFY_USERS", 1ULL << 3},
{"CM", 1ULL << 4},
{"SUPER", ~0ULL}
};
@ -231,12 +232,12 @@ class AOClient : public QObject {
{"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}},
{"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}},
{"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}},
{"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}},
{"invite", {ACLFlags.value("NONE"), 1, &AOClient::cmdInvite}},
{"uninvite", {ACLFlags.value("NONE"), 1, &AOClient::cmdUnInvite}},
{"lock", {ACLFlags.value("NONE"), 0, &AOClient::cmdLock}},
{"spectatable", {ACLFlags.value("NONE"), 0, &AOClient::cmdSpectatable}},
{"unlock", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnLock}},
{"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}},
{"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}},
{"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}},
{"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
{"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
{"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
};

View File

@ -264,10 +264,16 @@ void AOClient::sendServerBroadcast(QString message)
bool AOClient::checkAuth(unsigned long long acl_mask)
{
if (acl_mask != ACLFlags.value("NONE")) {
if (!authenticated) {
if (!authenticated && acl_mask != ACLFlags.value("CM")) {
return false;
}
if (acl_mask == ACLFlags.value("CM")) {
AreaData* area = server->areas[current_area];
if (area->owners.contains(id))
return true;
}
QSettings settings("config/config.ini", QSettings::IniFormat);
settings.beginGroup("Options");
QString auth_type = settings.value("auth", "simple").toString();

View File

@ -448,12 +448,8 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
AreaData* area = server->areas[current_area];
int removed = area->owners.removeAll(id);
area->invited.removeAll(id);
if (removed == 0)
sendServerMessage("You are not a CM in this area.");
else {
sendServerMessage("You are no longer CM in this area.");
arup(ARUPType::CM, true);
}
sendServerMessage("You are no longer CM in this area.");
arup(ARUPType::CM, true);
if (area->owners.isEmpty())
area->invited.clear();
}
@ -462,11 +458,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
AreaData* area = server->areas[current_area];
bool ok;
int invited_id = argv[0].toInt(&ok);
if (!area->owners.contains(id)) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (!ok) {
if (!ok) {
sendServerMessage("That does not look like a valid ID.");
return;
}
@ -482,11 +474,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
AreaData* area = server->areas[current_area];
bool ok;
int uninvited_id = argv[0].toInt(&ok);
if (!area->owners.contains(id)) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (!ok) {
if (!ok) {
sendServerMessage("That does not look like a valid ID.");
return;
}
@ -504,11 +492,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
void AOClient::cmdLock(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::LOCKED) {
if (area->locked == AreaData::LockStatus::LOCKED) {
sendServerMessage("This area is already locked.");
return;
}
@ -524,11 +508,7 @@ void AOClient::cmdLock(int argc, QStringList argv)
void AOClient::cmdSpectatable(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::SPECTATABLE) {
if (area->locked == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("This area is already in spectate mode.");
return;
}
@ -544,11 +524,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
void AOClient::cmdUnLock(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::FREE) {
if (area->locked == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked.");
return;
}