Fix cannot change user status to disabled
This commit is contained in:
@@ -18,6 +18,7 @@ package im
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/authentication"
|
||||
|
||||
@@ -70,7 +71,13 @@ func (im *imOperator) UpdateUser(new *iamv1alpha2.User) (*iamv1alpha2.User, erro
|
||||
}
|
||||
// keep encrypted password and user status
|
||||
new.Spec.EncryptedPassword = old.Spec.EncryptedPassword
|
||||
new.Status = old.Status
|
||||
status := old.Status
|
||||
// only support enable or disable
|
||||
if new.Status.State == iamv1alpha2.UserDisabled || new.Status.State == iamv1alpha2.UserActive {
|
||||
status.State = new.Status.State
|
||||
status.LastTransitionTime = &metav1.Time{Time: time.Now()}
|
||||
}
|
||||
new.Status = status
|
||||
updated, err := im.ksClient.IamV1alpha2().Users().Update(context.Background(), new, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user