@@ -38,6 +38,7 @@ import (
38
38
util4 "github.com/devtron-labs/devtron/pkg/appStore/util"
39
39
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
40
40
"github.com/devtron-labs/devtron/pkg/auth/user"
41
+ "github.com/devtron-labs/devtron/pkg/auth/user/bean"
41
42
bean5 "github.com/devtron-labs/devtron/pkg/cluster/bean"
42
43
bean2 "github.com/devtron-labs/devtron/pkg/cluster/environment/bean"
43
44
common2 "github.com/devtron-labs/devtron/pkg/deployment/common"
@@ -49,6 +50,7 @@ import (
49
50
k8sApplication "github.com/devtron-labs/devtron/pkg/k8s/application"
50
51
"github.com/devtron-labs/devtron/pkg/pipeline"
51
52
bean6 "github.com/devtron-labs/devtron/pkg/team/bean"
53
+ util2 "github.com/devtron-labs/devtron/util"
52
54
"github.com/devtron-labs/devtron/util/rbac"
53
55
"github.com/go-pg/pg"
54
56
"github.com/gorilla/mux"
@@ -469,6 +471,11 @@ func (handler AppListingRestHandlerImpl) FetchOverviewAppsByEnvironment(w http.R
469
471
}
470
472
471
473
func (handler AppListingRestHandlerImpl ) FetchAppDetailsV2 (w http.ResponseWriter , r * http.Request ) {
474
+ userId , err := handler .userService .GetLoggedInUser (r )
475
+ if userId == 0 || err != nil {
476
+ common .WriteJsonResp (w , err , "Unauthorized User" , http .StatusUnauthorized )
477
+ return
478
+ }
472
479
vars := mux .Vars (r )
473
480
token := r .Header .Get ("token" )
474
481
appId , err := strconv .Atoi (vars ["app-id" ])
@@ -486,14 +493,21 @@ func (handler AppListingRestHandlerImpl) FetchAppDetailsV2(w http.ResponseWriter
486
493
common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), nil , http .StatusForbidden )
487
494
return
488
495
}
496
+ isSuperAdmin := handler .enforcer .Enforce (token , casbin .ResourceGlobal , casbin .ActionCreate , "*" )
497
+ userEmail := util2 .GetEmailFromContext (r .Context ())
498
+ userMetadata := & bean.UserMetadata {
499
+ UserEmailId : userEmail ,
500
+ IsUserSuperAdmin : isSuperAdmin ,
501
+ UserId : userId ,
502
+ }
489
503
appDetail , err := handler .appListingService .FetchAppDetails (r .Context (), appId , envId )
490
504
if err != nil {
491
505
handler .logger .Errorw ("service err, FetchAppDetailsV2" , "err" , err , "appId" , appId , "envId" , envId )
492
506
common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
493
507
return
494
508
}
495
509
496
- appDetail , err = handler .updateApprovalConfigDataInAppDetailResp (appDetail , appId , envId )
510
+ appDetail , err = handler .updateApprovalConfigDataInAppDetailResp (r . Context (), appDetail , appId , envId , userMetadata )
497
511
if err != nil {
498
512
common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
499
513
return
0 commit comments