- // check if the login dataFile; if so, we know we are updating an existing user
- if acc, ok := cc.Server.Accounts[login]; ok {
- cc.logger.Infow("UpdateUser", "login", login)
+ // If FieldData is included, this is a rename operation where FieldData contains the login of the existing
+ // account and FieldUserLogin contains the new login.
+ if getField(FieldData, &subFields) != nil {
+ loginToRename = decodeString(getField(FieldData, &subFields).Data)
+ }
+ userLogin := decodeString(getField(FieldUserLogin, &subFields).Data)
+ if loginToRename != "" {
+ accountToUpdate = loginToRename
+ } else {
+ accountToUpdate = userLogin
+ }
+
+ // Check if accountToUpdate has an existing account. If so, we know we are updating an existing user.
+ if acc, ok := cc.Server.Accounts[accountToUpdate]; ok {
+ if loginToRename != "" {
+ cc.logger.Infow("RenameUser", "prevLogin", accountToUpdate, "newLogin", userLogin)
+ } else {
+ cc.logger.Infow("UpdateUser", "login", accountToUpdate)
+ }