From f1bb9d69acd1cbef520316777c64a0f459f2ad57 Mon Sep 17 00:00:00 2001 From: smartcat999 <49057502+smartcat999@users.noreply.github.com> Date: Fri, 28 Feb 2025 16:57:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Fixed=20the=20issue=20where=20the=20user?= =?UTF-8?q?=20status=20was=20empty=20when=20the=20third-p=E2=80=A6=20(#637?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Fixed the issue where the user status was empty when the third-p… (#2258) * fix: Fixed the issue where the user status was empty when the third-party login user logged in manually for the first time * fix: Fixed the issue where the user status was empty when the third-party login user logged in manually for the first time --------- Signed-off-by: peng wu <2030047311@qq.com> (cherry picked from commit 8056d176f8bf7e422cf4a3f14fa6c69acfa9b4a6) --- pkg/controller/user/user_controller.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/controller/user/user_controller.go b/pkg/controller/user/user_controller.go index 090ad6535..a53cc5684 100644 --- a/pkg/controller/user/user_controller.go +++ b/pkg/controller/user/user_controller.go @@ -269,13 +269,15 @@ func (r *Reconciler) reconcileUserStatus(ctx context.Context, user *iamv1beta1.U } // becomes active after password encrypted - if user.Status.State == "" && isEncrypted(user.Spec.EncryptedPassword) { - user.Status = iamv1beta1.UserStatus{ - State: iamv1beta1.UserActive, - LastTransitionTime: &metav1.Time{Time: time.Now()}, - } - if err := r.Update(ctx, user, &client.UpdateOptions{}); err != nil { - return err + if user.Status.State == "" { + if user.Spec.EncryptedPassword == "" || isEncrypted(user.Spec.EncryptedPassword) { + user.Status = iamv1beta1.UserStatus{ + State: iamv1beta1.UserActive, + LastTransitionTime: &metav1.Time{Time: time.Now()}, + } + if err := r.Update(ctx, user, &client.UpdateOptions{}); err != nil { + return err + } } }