Update canSynchronizeCarCatalogs to new auth concept
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -586,8 +586,8 @@ export default class Authorizations {
return Authorizations.canPerformAction(loggedUser, Entity.USERS_CARS, Action.ASSIGN);
}
- public static async canSynchronizeCarCatalogs(loggedUser: UserToken): Promise<boolean> {
- return Authorizations.canPerformAction(loggedUser, Entity.CAR_CATALOGS, Action.SYNCHRONIZE);
+ public static async canSynchronizeCarCatalogs(loggedUser: UserToken, authContext?: AuthorizationContext): Promise<AuthorizationResult> {
+ return Authorizations.can(loggedUser, Entity.CAR_CATALOG, Action.SYNCHRONIZE, authContext);
}
public static async canCreateCar(loggedUser: UserToken): Promise<boolean> {

MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -129,13 +129,10 @@ export default class CarService {
next();
}
- // todo: refactor
public static async handleSynchronizeCarCatalogs(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- if (!Authorizations.isSuperAdmin(req.user)) {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.CAR,
Action.SYNCHRONIZE, Entity.CAR_CATALOGS, MODULE_NAME, 'handleSynchronizeCarCatalogs');
- }
// Check auth
if (!await Authorizations.canSynchronizeCarCatalogs(req.user)) {
throw new AppAuthError({

Update canSynchronizeCarCatalogs to new auth concept