mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +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];
|
return privsAdmin.routeMap[path];
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = Object.entries(privsAdmin.routePrefixMap).find(entry => path.startsWith(entry[0]));
|
const found = Object.entries(privsAdmin.routePrefixMap)
|
||||||
return found ? found[1] : undefined;
|
.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) {
|
privsAdmin.list = async function (uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user