mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
fix: #11066, fix custom privilege/path in routePrefixMap
will find most specific path
This commit is contained in:
@@ -109,8 +109,13 @@ privsAdmin.resolve = (path) => {
|
||||
return privsAdmin.routeMap[path];
|
||||
}
|
||||
|
||||
const found = Object.entries(privsAdmin.routePrefixMap).find(entry => path.startsWith(entry[0]));
|
||||
return found ? found[1] : undefined;
|
||||
const found = Object.entries(privsAdmin.routePrefixMap)
|
||||
.filter(entry => path.startsWith(entry[0]))
|
||||
.sort((entry1, entry2) => entry2[0].length - entry1[0].length);
|
||||
if (!found.length) {
|
||||
return undefined;
|
||||
}
|
||||
return found[0][1]; // [0] is path [1] is privilege
|
||||
};
|
||||
|
||||
privsAdmin.list = async function (uid) {
|
||||
|
||||
Reference in New Issue
Block a user