From ff6a95123175b7dc6c7b7221861acd540fc58920 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Tue, 1 Apr 2025 22:18:49 +0800 Subject: [PATCH] isChangeRole --- server/service/staff_user.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/service/staff_user.go b/server/service/staff_user.go index a8ccc1c..92488cd 100644 --- a/server/service/staff_user.go +++ b/server/service/staff_user.go @@ -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) }