check if object exist before checking permission
MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -301,6 +301,8 @@ export default class SiteAreaService {
UtilsService.assertIdIsProvided(action, siteAreaID, MODULE_NAME, 'handleGetSiteAreaImage', req.user);
// Get it
const siteArea = await SiteAreaStorage.getSiteArea(req.user.tenantID, siteAreaID);
+ UtilsService.assertObjectExists(action, siteArea, `Site Area with ID '${siteAreaID}' does not exist`,
+ MODULE_NAME, 'handleGetSiteAreaImage', req.user);
// Check auth
if (!Authorizations.canReadSiteArea(req.user, siteArea.siteID)) {
throw new AppAuthError({
@@ -311,8 +313,6 @@ export default class SiteAreaService {
value: siteAreaID
});
}
- UtilsService.assertObjectExists(action, siteArea, `Site Area with ID '${siteAreaID}' does not exist`,
- MODULE_NAME, 'handleGetSiteAreaImage', req.user);
// Get it
const siteAreaImage = await SiteAreaStorage.getSiteAreaImage(req.user.tenantID, siteAreaID);
// Return

check if object exist before checking permission