fix(admin): Able to change deafult user status (#1811)
This commit is contained in:
parent
ce832bf13d
commit
3ffce1e356
1 changed files with 7 additions and 2 deletions
|
@ -112,8 +112,13 @@ func (service *AddUserService) Add() serializer.Response {
|
||||||
user.TwoFactor = service.User.TwoFactor
|
user.TwoFactor = service.User.TwoFactor
|
||||||
|
|
||||||
// 检查愚蠢操作
|
// 检查愚蠢操作
|
||||||
if user.ID == 1 && user.GroupID != 1 {
|
if user.ID == 1 {
|
||||||
return serializer.Err(serializer.CodeChangeGroupForDefaultUser, "", nil)
|
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 {
|
if err := model.DB.Save(&user).Error; err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue