Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions app/api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class APIClass extends Restivus {
importIds: 0,
e2e: 0,
};
this.limitedUserFieldsToExclude = {
this.defaultLimitedUserFieldsToExclude = {
avatarOrigin: 0,
emails: 0,
phone: 0,
Expand All @@ -53,14 +53,25 @@ export class APIClass extends Restivus {
roles: 0,
statusDefault: 0,
_updatedAt: 0,
customFields: 0,
settings: 0,
};
this.limitedUserFieldsToExclude = this.defaultLimitedUserFieldsToExclude;
this.limitedUserFieldsToExcludeIfIsPrivilegedUser = {
services: 0,
};
}

setLimitedCustomFields(customFields) {
const nonPublicFieds = customFields.reduce((acc, customField) => {
acc[`customFields.${ customField }`] = 0;
return acc;
}, {});
this.limitedUserFieldsToExclude = {
...this.defaultLimitedUserFieldsToExclude,
...nonPublicFieds,
};
}

hasHelperMethods() {
return API.helperMethods.size !== 0;
}
Expand Down Expand Up @@ -599,6 +610,17 @@ settings.get('API_Enable_CORS', (key, value) => {
createApi(value);
});

settings.get('Accounts_CustomFields', (key, value) => {
try {
const customFields = JSON.parse(value);
const nonPublicCustomFields = Object.keys(customFields).filter((customFieldKey) => customFields[customFieldKey].public !== true);
API.v1.setLimitedCustomFields(nonPublicCustomFields);
} catch (error) {
logger.warn('Invalid Custom Fields', error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.warn('Invalid Custom Fields', error);

I don't see a reason to show the warn message twice, so leaving only the console.warn below I think is enough

console.warn('Invalid Custom Fields', error);
}
});

settings.get('API_Enable_Rate_Limiter_Limit_Time_Default', (key, value) => {
defaultRateLimiterOptions.intervalTimeInMS = value;
API.v1.reloadRoutesToRefreshRateLimiter();
Expand Down