@@ -3,6 +3,8 @@ import { ConfigurationService } from './configuration.service';
33import { Server } from 'socket.io' ;
44import { Configuration } from './configuration.interface' ;
55import { PlatformTypes } from '../enums' ;
6+ import { UseGuards } from '@nestjs/common' ;
7+ import { AuthGuard } from '../guards/auth.guard' ;
68
79@WebSocketGateway ( )
810export class ConfigurationGateway {
@@ -21,48 +23,60 @@ export class ConfigurationGateway {
2123 return { event : `panel.configurations.gateways` , data : configs } ;
2224 }
2325
26+ @UseGuards ( AuthGuard )
2427 @SubscribeMessage ( 'panel.configurations.storefront.add' )
2528 async addStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
29+ delete ( body as any ) . auth ;
2630 if ( ! body . configurations ) return null ;
2731 await this . configurationService . add ( PlatformTypes . Storefront , body . name , body . configurations ) ;
2832 this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
2933 this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
3034 }
3135
36+ @UseGuards ( AuthGuard )
3237 @SubscribeMessage ( 'panel.configurations.gateway.add' )
3338 async addGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
39+ delete ( body as any ) . auth ;
3440 if ( ! body . configurations ) return null ;
3541 await this . configurationService . add ( PlatformTypes . Gateway , body . name , body . configurations ) ;
3642 this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
3743 this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
3844 }
3945
46+ @UseGuards ( AuthGuard )
4047 @SubscribeMessage ( 'panel.configurations.storefront.update' )
4148 async updateStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
49+ delete ( body as any ) . auth ;
4250 if ( ! body . configurations ) return null ;
4351 await this . configurationService . update ( PlatformTypes . Storefront , body . name , body . configurations ) ;
4452 this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
4553 this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
4654 }
4755
56+ @UseGuards ( AuthGuard )
4857 @SubscribeMessage ( 'panel.configurations.gateway.update' )
4958 async updateGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
59+ delete ( body as any ) . auth ;
5060 if ( ! body . configurations ) return null ;
5161 await this . configurationService . update ( PlatformTypes . Gateway , body . name , body . configurations ) ;
5262 this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
5363 this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
5464 }
5565
66+ @UseGuards ( AuthGuard )
5667 @SubscribeMessage ( 'panel.configurations.storefront.delete' )
5768 async deleteStorefrontConfigs ( @MessageBody ( ) body : { name : string } ) {
69+ delete ( body as any ) . auth ;
5870 if ( ! body . name ) return null ;
5971 await this . configurationService . delete ( PlatformTypes . Storefront , body . name ) ;
6072 this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
6173 this . server . emit ( `configurations.storefront.delete` , body . name ) ;
6274 }
6375
76+ @UseGuards ( AuthGuard )
6477 @SubscribeMessage ( 'panel.configurations.gateway.delete' )
6578 async deleteGatewayConfigs ( @MessageBody ( ) body : { name : string } ) {
79+ delete ( body as any ) . auth ;
6680 if ( ! body . name ) return null ;
6781 await this . configurationService . delete ( PlatformTypes . Gateway , body . name ) ;
6882 this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
0 commit comments