Added more info on inactive component when AuthError is thrown
MODIFY
src/exception/AppAuthError.ts
src/exception/AppAuthError.ts
@@ -4,6 +4,7 @@ import { HTTPAuthError } from '../types/HTTPError';
import User from '../types/User';
import UserToken from '../types/UserToken';
import Utils from '../utils/Utils';
+import TenantComponents from '../types/TenantComponents';
export default class AppAuthError extends Error {
@@ -15,8 +16,9 @@ export default class AppAuthError extends Error {
module: string;
method: string;
user: UserToken;
+ inactiveComponent?: TenantComponents,
actionOnUser?: User | UserToken | string;
}) {
- super(`Role ${Utils.getRoleNameFromRoleID(params.user.role)} is not authorized to perform ${params.action} on ${params.entity}${(params.value ? ' \'' + params.value + '\'' : '')}`);
+ super(`${params.inactiveComponent ? 'Component \'' + params.inactiveComponent + '\' is not active - ' : ''}Role ${Utils.getRoleNameFromRoleID(params.user.role)} is not authorized to perform ${params.action} on ${params.entity}${(params.value ? ' \'' + params.value + '\'' : '')}`);
}
}

MODIFY
src/server/rest/service/UtilsService.ts
src/server/rest/service/UtilsService.ts
@@ -64,10 +64,9 @@ export default class UtilsService {
if (!active) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
- entity: entity,
- action: action,
- module: module,
- method: method,
+ entity: entity, action: action,
+ module: module, method: method,
+ inactiveComponent: component,
user: userToken
});
}

Added more info on inactive component when AuthError is thrown