|
@@ -227,10 +227,10 @@ func (us *UserService) Delete(u *model.User) error {
|
|
227
|
func (us *UserService) Update(u *model.User) error {
|
227
|
func (us *UserService) Update(u *model.User) error {
|
|
228
|
currentUser := us.InfoById(u.Id)
|
228
|
currentUser := us.InfoById(u.Id)
|
|
229
|
// 如果当前用户是管理员并且 IsAdmin 不为空,进行检查
|
229
|
// 如果当前用户是管理员并且 IsAdmin 不为空,进行检查
|
|
230
|
- if currentUser.IsAdmin != nil && *currentUser.IsAdmin {
|
|
|
|
|
|
230
|
+ if us.IsAdmin(currentUser) {
|
|
231
|
adminCount := us.getAdminUserCount()
|
231
|
adminCount := us.getAdminUserCount()
|
|
232
|
// 如果这是唯一的管理员,确保不能禁用或取消管理员权限
|
232
|
// 如果这是唯一的管理员,确保不能禁用或取消管理员权限
|
|
233
|
- if adminCount <= 1 && (u.IsAdmin == nil || !*u.IsAdmin || u.Status == model.COMMON_STATUS_DISABLED) {
|
|
|
|
|
|
233
|
+ if adminCount <= 1 && ( !us.IsAdmin(u) || u.Status == model.COMMON_STATUS_DISABLED) {
|
|
234
|
return errors.New("The last admin user cannot be disabled or demoted")
|
234
|
return errors.New("The last admin user cannot be disabled or demoted")
|
|
235
|
}
|
235
|
}
|
|
236
|
}
|
236
|
}
|