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:
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user