mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 23:30:36 +01:00
get whitelisted fields from plugins as well
This commit is contained in:
@@ -189,7 +189,7 @@ User.exportUsersCSV = async function (socket, data) {
|
||||
};
|
||||
|
||||
User.saveCustomFields = async function (socket, fields) {
|
||||
const userFields = user.getUserFieldWhitelist();
|
||||
const userFields = await user.getUserFieldWhitelist();
|
||||
for (const field of fields) {
|
||||
if (userFields.includes(field.key) || userFields.includes(field.key.toLowerCase())) {
|
||||
throw new Error(`[[error:invalid-custom-user-field, ${field.key}]]`);
|
||||
|
||||
@@ -52,8 +52,12 @@ module.exports = function (User) {
|
||||
customFieldWhiteList = await db.getSortedSetRange('user-custom-fields', 0, -1);
|
||||
};
|
||||
|
||||
User.getUserFieldWhitelist = function () {
|
||||
return fieldWhitelist.slice();
|
||||
User.getUserFieldWhitelist = async function () {
|
||||
const { whitelist } = await plugins.hooks.fire('filter:user.whitelistFields', {
|
||||
uids: [],
|
||||
whitelist: fieldWhitelist.slice(),
|
||||
});
|
||||
return whitelist;
|
||||
};
|
||||
|
||||
User.getUsersFields = async function (uids, fields) {
|
||||
|
||||
Reference in New Issue
Block a user