Disable create service account button if no policy (#1006)

* disable button if no policies

* merge fix

* finding group policies

* fixing style

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Co-authored-by: Adam Stafford <adamstafford@Adams-MacBook-Pro.local>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
This commit is contained in:
adfost
2021-09-07 15:02:04 -07:00
committed by GitHub
parent 13cf3e6fa1
commit 1d88bb491d
6 changed files with 43 additions and 3 deletions

View File

@@ -281,11 +281,35 @@ func getUserInfoResponse(session *models.Principal, params admin_api.GetUserInfo
return nil, prepareError(err)
}
var policies []string
if user.PolicyName == "" {
policies = []string{}
} else {
policies = strings.Split(user.PolicyName, ",")
}
hasPolicy := true
if len(policies) == 0 {
hasPolicy = false
for i := 0; i < len(user.MemberOf); i++ {
group, err := adminClient.getGroupDescription(ctx, user.MemberOf[i])
if err != nil {
continue
}
if group.Policy != "" {
hasPolicy = true
break
}
}
}
userInformation := &models.User{
AccessKey: params.Name,
MemberOf: user.MemberOf,
Policy: strings.Split(user.PolicyName, ","),
Policy: policies,
Status: string(user.Status),
HasPolicy: hasPolicy,
}
return userInformation, nil

View File

@@ -5454,6 +5454,9 @@ func init() {
"accessKey": {
"type": "string"
},
"hasPolicy": {
"type": "boolean"
},
"memberOf": {
"type": "array",
"items": {
@@ -11049,6 +11052,9 @@ func init() {
"accessKey": {
"type": "string"
},
"hasPolicy": {
"type": "boolean"
},
"memberOf": {
"type": "array",
"items": {