From 3ffce1e356eea19bdef9058f0c7fd9aad1f6833b Mon Sep 17 00:00:00 2001 From: Sam <100821827+01101sam@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:24:58 +0800 Subject: [PATCH] fix(admin): Able to change deafult user status (#1811) --- service/admin/user.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/service/admin/user.go b/service/admin/user.go index 0b66deb50a..eb76ac9aca 100644 --- a/service/admin/user.go +++ b/service/admin/user.go @@ -112,8 +112,13 @@ func (service *AddUserService) Add() serializer.Response { user.TwoFactor = service.User.TwoFactor // 检查愚蠢操作 - if user.ID == 1 && user.GroupID != 1 { - return serializer.Err(serializer.CodeChangeGroupForDefaultUser, "", nil) + if user.ID == 1 { + if user.GroupID != 1 { + return serializer.Err(serializer.CodeChangeGroupForDefaultUser, "", nil) + } + if user.Status != model.Active { + return serializer.Err(serializer.CodeInvalidActionOnDefaultUser, "", nil) + } } if err := model.DB.Save(&user).Error; err != nil {