Fix get setting by identifier
MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -54,7 +54,7 @@ export default class SettingService {
// Filter
const settingID = SettingValidatorRest.getInstance().validateSettingGetByIdentifierReq(req.query).Identifier;
// Get it
- const setting = await UtilsService.checkAndGetSettingAuthorization(req.tenant, req.user, settingID, Action.READ, action, {}, {}, true);
+ const setting = await UtilsService.checkAndGetSettingAuthorization(req.tenant, req.user, settingID, Action.READ, action, {}, { identifier: settingID }, true);
// Process the sensitive data if any
SettingService.hashSensitiveData(setting);
res.json(setting);

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -822,10 +822,18 @@ export default class UtilsService {
const authorizations = await AuthorizationService.checkAndGetSettingAuthorizations(
tenant, userToken, { ID: settingID }, authAction, entityData);
// Get Setting
- const setting = await SettingStorage.getSetting(tenant, settingID,
+ let setting;
+ if (additionalFilters?.identifier) {
+ setting = await SettingStorage.getSettingByIdentifier(tenant, settingID,
applyProjectFields ? authorizations.projectFields : null
);
- UtilsService.assertObjectExists(action, setting, `Setting ID '${settingID}' does not exist`,
+ } else {
+ setting = await SettingStorage.getSetting(tenant, settingID,
+ applyProjectFields ? authorizations.projectFields : null
+ );
+ }
+
+ UtilsService.assertObjectExists(action, setting, `Setting '${settingID}' does not exist`,
MODULE_NAME, 'checkAndGetSettingAuthorization', userToken);
// Assign projected fields
if (authorizations.projectFields) {

Fix get setting by identifier