isChangeRole

This commit is contained in:
jiangyong27 2025-04-01 22:18:49 +08:00
parent db92e99698
commit ff6a951231
1 changed files with 8 additions and 0 deletions

View File

@ -180,9 +180,17 @@ func (s *StaffUser) Update(sess *session.AdminSession, req *api.StaffUpdateReq)
if oldCfg == nil {
oldCfg = make(map[string]interface{})
}
isChangeRole := false
for k, v := range newCfg {
oldCfg[k] = v
if k == "user_role" {
isChangeRole = true
}
}
if isChangeRole && !sess.GetAdmin().GetConfig().IsAdmin() {
panic(config.ErrPriv.New())
}
staffUser.Config = goutil.EncodeJSON(oldCfg)
}