SetUserStatus - sets current user status.
(ctx context.Context, accessKey string, status madmin.AccountStatus)
| 2092 | |
| 2093 | // SetUserStatus - sets current user status. |
| 2094 | func (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 |
| 2136 | func (store *IAMStoreSys) AddServiceAccount(ctx context.Context, cred auth.Credentials) (updatedAt time.Time, err error) { |
nothing calls this directly
no test coverage detected