@@ -3,6 +3,8 @@ import { ConfigurationService } from './configuration.service';
3
3
import { Server } from 'socket.io' ;
4
4
import { Configuration } from './configuration.interface' ;
5
5
import { PlatformTypes } from '../enums' ;
6
+ import { UseGuards } from '@nestjs/common' ;
7
+ import { AuthGuard } from '../guards/auth.guard' ;
6
8
7
9
@WebSocketGateway ( )
8
10
export class ConfigurationGateway {
@@ -21,48 +23,60 @@ export class ConfigurationGateway {
21
23
return { event : `panel.configurations.gateways` , data : configs } ;
22
24
}
23
25
26
+ @UseGuards ( AuthGuard )
24
27
@SubscribeMessage ( 'panel.configurations.storefront.add' )
25
28
async addStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
29
+ delete ( body as any ) . auth ;
26
30
if ( ! body . configurations ) return null ;
27
31
await this . configurationService . add ( PlatformTypes . Storefront , body . name , body . configurations ) ;
28
32
this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
29
33
this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
30
34
}
31
35
36
+ @UseGuards ( AuthGuard )
32
37
@SubscribeMessage ( 'panel.configurations.gateway.add' )
33
38
async addGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
39
+ delete ( body as any ) . auth ;
34
40
if ( ! body . configurations ) return null ;
35
41
await this . configurationService . add ( PlatformTypes . Gateway , body . name , body . configurations ) ;
36
42
this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
37
43
this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
38
44
}
39
45
46
+ @UseGuards ( AuthGuard )
40
47
@SubscribeMessage ( 'panel.configurations.storefront.update' )
41
48
async updateStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
49
+ delete ( body as any ) . auth ;
42
50
if ( ! body . configurations ) return null ;
43
51
await this . configurationService . update ( PlatformTypes . Storefront , body . name , body . configurations ) ;
44
52
this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
45
53
this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
46
54
}
47
55
56
+ @UseGuards ( AuthGuard )
48
57
@SubscribeMessage ( 'panel.configurations.gateway.update' )
49
58
async updateGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
59
+ delete ( body as any ) . auth ;
50
60
if ( ! body . configurations ) return null ;
51
61
await this . configurationService . update ( PlatformTypes . Gateway , body . name , body . configurations ) ;
52
62
this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
53
63
this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
54
64
}
55
65
66
+ @UseGuards ( AuthGuard )
56
67
@SubscribeMessage ( 'panel.configurations.storefront.delete' )
57
68
async deleteStorefrontConfigs ( @MessageBody ( ) body : { name : string } ) {
69
+ delete ( body as any ) . auth ;
58
70
if ( ! body . name ) return null ;
59
71
await this . configurationService . delete ( PlatformTypes . Storefront , body . name ) ;
60
72
this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
61
73
this . server . emit ( `configurations.storefront.delete` , body . name ) ;
62
74
}
63
75
76
+ @UseGuards ( AuthGuard )
64
77
@SubscribeMessage ( 'panel.configurations.gateway.delete' )
65
78
async deleteGatewayConfigs ( @MessageBody ( ) body : { name : string } ) {
79
+ delete ( body as any ) . auth ;
66
80
if ( ! body . name ) return null ;
67
81
await this . configurationService . delete ( PlatformTypes . Gateway , body . name ) ;
68
82
this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
0 commit comments