Browse Source

fix(core): Correct some permissions in Channel & Promotion resolvers

Michael Bromley 6 years ago
parent
commit
e2a64fa466

+ 2 - 2
packages/core/src/api/resolvers/admin/channel.resolver.ts

@@ -17,13 +17,13 @@ export class ChannelResolver {
     constructor(private channelService: ChannelService) {}
     constructor(private channelService: ChannelService) {}
 
 
     @Query()
     @Query()
-    @Allow(Permission.SuperAdmin)
+    @Allow(Permission.ReadSettings)
     channels(@Ctx() ctx: RequestContext): Promise<Channel[]> {
     channels(@Ctx() ctx: RequestContext): Promise<Channel[]> {
         return this.channelService.findAll();
         return this.channelService.findAll();
     }
     }
 
 
     @Query()
     @Query()
-    @Allow(Permission.SuperAdmin)
+    @Allow(Permission.ReadSettings)
     async channel(@Ctx() ctx: RequestContext, @Args() args: QueryChannelArgs): Promise<Channel | undefined> {
     async channel(@Ctx() ctx: RequestContext, @Args() args: QueryChannelArgs): Promise<Channel | undefined> {
         return this.channelService.findOne(args.id);
         return this.channelService.findOne(args.id);
     }
     }

+ 7 - 7
packages/core/src/api/resolvers/admin/promotion.resolver.ts

@@ -22,7 +22,7 @@ export class PromotionResolver {
     constructor(private promotionService: PromotionService, private idCodecService: IdCodecService) {}
     constructor(private promotionService: PromotionService, private idCodecService: IdCodecService) {}
 
 
     @Query()
     @Query()
-    @Allow(Permission.ReadSettings)
+    @Allow(Permission.ReadPromotion)
     promotions(
     promotions(
         @Ctx() ctx: RequestContext,
         @Ctx() ctx: RequestContext,
         @Args() args: QueryPromotionsArgs,
         @Args() args: QueryPromotionsArgs,
@@ -34,25 +34,25 @@ export class PromotionResolver {
     }
     }
 
 
     @Query()
     @Query()
-    @Allow(Permission.ReadSettings)
+    @Allow(Permission.ReadPromotion)
     promotion(@Ctx() ctx: RequestContext, @Args() args: QueryPromotionArgs): Promise<Promotion | undefined> {
     promotion(@Ctx() ctx: RequestContext, @Args() args: QueryPromotionArgs): Promise<Promotion | undefined> {
         return this.promotionService.findOne(args.id).then(this.encodeConditionsAndActions);
         return this.promotionService.findOne(args.id).then(this.encodeConditionsAndActions);
     }
     }
 
 
     @Query()
     @Query()
-    @Allow(Permission.ReadSettings)
+    @Allow(Permission.ReadPromotion)
     promotionConditions(@Ctx() ctx: RequestContext) {
     promotionConditions(@Ctx() ctx: RequestContext) {
         return this.promotionService.getPromotionConditions(ctx);
         return this.promotionService.getPromotionConditions(ctx);
     }
     }
 
 
     @Query()
     @Query()
-    @Allow(Permission.ReadSettings)
+    @Allow(Permission.ReadPromotion)
     promotionActions(@Ctx() ctx: RequestContext) {
     promotionActions(@Ctx() ctx: RequestContext) {
         return this.promotionService.getPromotionActions(ctx);
         return this.promotionService.getPromotionActions(ctx);
     }
     }
 
 
     @Mutation()
     @Mutation()
-    @Allow(Permission.CreateSettings)
+    @Allow(Permission.CreatePromotion)
     createPromotion(
     createPromotion(
         @Ctx() ctx: RequestContext,
         @Ctx() ctx: RequestContext,
         @Args() args: MutationCreatePromotionArgs,
         @Args() args: MutationCreatePromotionArgs,
@@ -63,7 +63,7 @@ export class PromotionResolver {
     }
     }
 
 
     @Mutation()
     @Mutation()
-    @Allow(Permission.UpdateSettings)
+    @Allow(Permission.UpdatePromotion)
     updatePromotion(
     updatePromotion(
         @Ctx() ctx: RequestContext,
         @Ctx() ctx: RequestContext,
         @Args() args: MutationUpdatePromotionArgs,
         @Args() args: MutationUpdatePromotionArgs,
@@ -74,7 +74,7 @@ export class PromotionResolver {
     }
     }
 
 
     @Mutation()
     @Mutation()
-    @Allow(Permission.DeleteSettings)
+    @Allow(Permission.DeletePromotion)
     deletePromotion(@Args() args: MutationDeletePromotionArgs): Promise<DeletionResponse> {
     deletePromotion(@Args() args: MutationDeletePromotionArgs): Promise<DeletionResponse> {
         return this.promotionService.softDeletePromotion(args.id);
         return this.promotionService.softDeletePromotion(args.id);
     }
     }