MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / SetUserStatus

Method SetUserStatus

cmd/iam-store.go:2094–2133  ·  view source on GitHub ↗

SetUserStatus - sets current user status.

(ctx context.Context, accessKey string, status madmin.AccountStatus)

Source from the content-addressed store, hash-verified

2092
2093// SetUserStatus - sets current user status.
2094func (store *IAMStoreSys) SetUserStatus(ctx context.Context, accessKey string, status madmin.AccountStatus) (updatedAt time.Time, err error) {
2095 if accessKey != "" && status != madmin.AccountEnabled && status != madmin.AccountDisabled {
2096 return updatedAt, errInvalidArgument
2097 }
2098
2099 cache := store.lock()
2100 defer store.unlock()
2101
2102 ui, ok := cache.iamUsersMap[accessKey]
2103 if !ok {
2104 return updatedAt, errNoSuchUser
2105 }
2106 cred := ui.Credentials
2107
2108 if cred.IsTemp() || cred.IsServiceAccount() {
2109 return updatedAt, errIAMActionNotAllowed
2110 }
2111
2112 uinfo := newUserIdentity(auth.Credentials{
2113 AccessKey: accessKey,
2114 SecretKey: cred.SecretKey,
2115 Status: func() string {
2116 switch string(status) {
2117 case string(madmin.AccountEnabled), string(auth.AccountOn):
2118 return auth.AccountOn
2119 }
2120 return auth.AccountOff
2121 }(),
2122 })
2123
2124 if err := store.saveUserIdentity(ctx, accessKey, regUser, uinfo); err != nil {
2125 return updatedAt, err
2126 }
2127
2128 if err := cache.updateUserWithClaims(accessKey, uinfo); err != nil {
2129 return updatedAt, err
2130 }
2131
2132 return uinfo.UpdatedAt, nil
2133}
2134
2135// AddServiceAccount - add a new service account
2136func (store *IAMStoreSys) AddServiceAccount(ctx context.Context, cred auth.Credentials) (updatedAt time.Time, err error) {

Callers

nothing calls this directly

Calls 7

newUserIdentityFunction · 0.85
IsTempMethod · 0.80
updateUserWithClaimsMethod · 0.80
lockMethod · 0.65
unlockMethod · 0.65
saveUserIdentityMethod · 0.65
IsServiceAccountMethod · 0.45

Tested by

no test coverage detected