@@ -96,6 +96,7 @@ func GetWorkspaceSubscriptionInfo(c *gin.Context) {
9696 * types.WorkspaceSubscription
9797 Type string `json:"type"`
9898 InvoiceInfo * InvoiceInfo `json:"InvoiceInfo,omitempty"`
99+ Role string `json:"role,omitempty"`
99100 }{
100101 WorkspaceSubscription : subscription ,
101102 Type : WorkspaceTypeSubscription ,
@@ -195,6 +196,13 @@ func GetWorkspaceSubscriptionInfo(c *gin.Context) {
195196 )
196197 }
197198 }
199+ // Get user workspace role
200+ userRole , err := dao .DBClient .GetUserWorkspaceRole (req .UserUID , req .Workspace )
201+ if err != nil {
202+ dao .Logger .Errorf ("failed to get user workspace role: %v" , err )
203+ // Continue processing, role will be empty string
204+ }
205+ workspaceSubInfo .Role = string (userRole )
198206 }
199207
200208 c .JSON (http .StatusOK , gin.H {
@@ -668,12 +676,14 @@ func GetWorkspaceSubscriptionUpgradeAmount(c *gin.Context) {
668676 )
669677 return
670678 }
671- if err := authenticateWorkspaceSubscriptionOperatorRequest (c , req ); err != nil {
672- c .JSON (
673- http .StatusUnauthorized ,
674- helper.ErrorMessage {Error : fmt .Sprintf ("authenticate error : %v" , err )},
675- )
676- return
679+ if req .Workspace != "" {
680+ if err := authenticateWorkspaceSubscriptionOperatorRequest (c , req ); err != nil {
681+ c .JSON (
682+ http .StatusUnauthorized ,
683+ helper.ErrorMessage {Error : fmt .Sprintf ("authenticate error : %v" , err )},
684+ )
685+ return
686+ }
677687 }
678688
679689 // Validate promotion code once at the beginning and reuse the result throughout the method
@@ -739,7 +749,7 @@ func GetWorkspaceSubscriptionUpgradeAmount(c *gin.Context) {
739749
740750 // Handle subscription creation
741751 if req .Operator == types .SubscriptionTransactionTypeCreated ||
742- currentSubscription .PlanName == types .FreeSubscriptionPlanName {
752+ currentSubscription .PlanName == types .FreeSubscriptionPlanName || req . Workspace == "" {
743753 handleSubscriptionCreation (c , req , validatedPromotionCode )
744754 return
745755 }
0 commit comments