Skip to content

Commit

Permalink
fix: do not update user status if has been initialized (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: liuyu <>
  • Loading branch information
eball authored Sep 24, 2024
1 parent 48d4928 commit 3965114
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions pkg/apis/settings/v1alpha1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,26 +600,30 @@ func (h *Handler) handleUpdateLocale(req *restful.Request, resp *restful.Respons

defer func() {
if err != nil {
if e := userOp.UpdateUser(user, []func(*iamV1alpha2.User){
func(u *iamV1alpha2.User) {
u.Annotations[constants.UserTerminusWizardStatus] = string(constants.SystemActivateFailed)
},
}); e != nil {
klog.Errorf("update user err, %v", err)
if user.Annotations[constants.UserTerminusWizardStatus] != string(constants.Completed) {
if e := userOp.UpdateUser(user, []func(*iamV1alpha2.User){
func(u *iamV1alpha2.User) {
u.Annotations[constants.UserTerminusWizardStatus] = string(constants.SystemActivateFailed)
},
}); e != nil {
klog.Errorf("update user err, %v", err)
}
}
}
}()

err = userOp.UpdateUser(user, []func(*iamV1alpha2.User){
func(u *iamV1alpha2.User) {
u.Annotations[constants.UserTerminusWizardStatus] = string(constants.SystemActivating)
},
})
if user.Annotations[constants.UserTerminusWizardStatus] != string(constants.Completed) {
err = userOp.UpdateUser(user, []func(*iamV1alpha2.User){
func(u *iamV1alpha2.User) {
u.Annotations[constants.UserTerminusWizardStatus] = string(constants.SystemActivating)
},
})

if err != nil {
klog.Errorf("update user err, %v", err)
response.HandleError(resp, errors.Errorf("update user locale data error: %v", err))
return
if err != nil {
klog.Errorf("update user err, %v", err)
response.HandleError(resp, errors.Errorf("update user locale data error: %v", err))
return
}
}

err = req.ReadEntity(&locale)
Expand All @@ -645,7 +649,9 @@ func (h *Handler) handleUpdateLocale(req *restful.Request, resp *restful.Respons
}
u.Annotations[constants.UserTheme] = locale.Theme

u.Annotations[constants.UserTerminusWizardStatus] = string(constants.WaitActivateNetwork)
if u.Annotations[constants.UserTerminusWizardStatus] != string(constants.Completed) {
u.Annotations[constants.UserTerminusWizardStatus] = string(constants.WaitActivateNetwork)
}
},
}); err != nil {
return errors.Errorf("update user err, %v", err)
Expand Down

0 comments on commit 3965114

Please sign in to comment.