Skip to content

Commit

Permalink
fix(admin): Able to change deafult user status (#1811)
Browse files Browse the repository at this point in the history
  • Loading branch information
01101sam authored Aug 14, 2023
1 parent ce832bf commit 3ffce1e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions service/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3ffce1e

Please sign in to comment.