@@ -14,7 +14,7 @@ type SubscriptionEndpoint struct{ BaseEndpoint }
14
14
15
15
// Subscribe function
16
16
func (subscriptionEndpoint * SubscriptionEndpoint ) Subscribe (ctx * fiber.Ctx ) error {
17
- if can := userEndpoint .Can (ctx , models .AdminRole ); can != true {
17
+ if can := userEndpoint .Can (ctx , models .AdminRole ); ! can {
18
18
return ctx .Status (401 ).JSON (fiber.Map {
19
19
"message" : "You are not authorized to perform this action" ,
20
20
})
@@ -40,7 +40,7 @@ func (subscriptionEndpoint *SubscriptionEndpoint) Subscribe(ctx *fiber.Ctx) erro
40
40
41
41
// GetCustomer function
42
42
func (subscriptionEndpoint * SubscriptionEndpoint ) GetCustomer (ctx * fiber.Ctx ) error {
43
- if can := userEndpoint .Can (ctx , models .AdminRole ); can != true {
43
+ if can := userEndpoint .Can (ctx , models .AdminRole ); ! can {
44
44
return ctx .Status (401 ).JSON (fiber.Map {
45
45
"message" : "You are not authorized to perform this action" ,
46
46
})
@@ -57,7 +57,7 @@ func (subscriptionEndpoint *SubscriptionEndpoint) GetCustomer(ctx *fiber.Ctx) er
57
57
58
58
// GetCustomerInvoices function
59
59
func (subscriptionEndpoint * SubscriptionEndpoint ) GetCustomerInvoices (ctx * fiber.Ctx ) error {
60
- if can := userEndpoint .Can (ctx , models .AdminRole ); can != true {
60
+ if can := userEndpoint .Can (ctx , models .AdminRole ); ! can {
61
61
return ctx .Status (401 ).JSON (fiber.Map {
62
62
"message" : "You are not authorized to perform this action" ,
63
63
})
@@ -75,7 +75,7 @@ func (subscriptionEndpoint *SubscriptionEndpoint) GetCustomerInvoices(ctx *fiber
75
75
76
76
// GetCustomerCards function
77
77
func (subscriptionEndpoint * SubscriptionEndpoint ) GetCustomerCards (ctx * fiber.Ctx ) error {
78
- if can := userEndpoint .Can (ctx , models .AdminRole ); can != true {
78
+ if can := userEndpoint .Can (ctx , models .AdminRole ); ! can {
79
79
return ctx .Status (401 ).JSON (fiber.Map {
80
80
"message" : "You are not authorized to perform this action" ,
81
81
})
@@ -103,6 +103,11 @@ func (subscriptionEndpoint *SubscriptionEndpoint) CancelSubscription(ctx *fiber.
103
103
_ , err := govalidator .ValidateMap (inputMap , map [string ]interface {}{
104
104
"subscriptionId" : "ascii,required" ,
105
105
})
106
+ if err != nil {
107
+ return ctx .Status (401 ).JSON (fiber.Map {
108
+ "message" : err .Error (),
109
+ })
110
+ }
106
111
account , _ := userEndpoint .CurrentAccount (ctx )
107
112
sCustomer , err := subscriptionService .CancelSubscription (account .ID , inputMap ["subscriptionId" ].(string ))
108
113
if err != nil {
0 commit comments