* fix: #9622

dont allow regular user to remove system tags

* refactor: add guest/spider check to isPrivileged

string/trim tag
v1.18.x
Barış Soner Uşaklı 4 years ago committed by GitHub
parent 0d975bc4fb
commit 1bf263c4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,7 +32,7 @@ module.exports = function (SocketTopics) {
const systemTags = (meta.config.systemTags || '').split(',');
const isPrivileged = await user.isPrivileged(socket.uid);
return isPrivileged || !systemTags.includes(data.tag);
return isPrivileged || !systemTags.includes(String(data.tag).trim());
};
SocketTopics.autocompleteTags = async function (socket, data) {

@ -159,6 +159,9 @@ User.getPrivileges = async function (uid) {
};
User.isPrivileged = async function (uid) {
if (!(parseInt(uid, 10) > 0)) {
return false;
}
const results = await User.getPrivileges(uid);
return results ? (results.isAdmin || results.isGlobalModerator || results.isModeratorOfAnyCategory) : false;
};

Loading…
Cancel
Save