Fix 500 error if there is a name conflict when edit authentication source (#23832)
This commit is contained in:
parent
7df036f1a5
commit
6e58f8400e
2 changed files with 12 additions and 3 deletions
|
@ -317,7 +317,14 @@ func UpdateSource(source *Source) error {
|
|||
}
|
||||
}
|
||||
|
||||
_, err := db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
|
||||
has, err := db.GetEngine(db.DefaultContext).Where("name=? AND id!=?", source.Name, source.ID).Exist(new(Source))
|
||||
if err != nil {
|
||||
return err
|
||||
} else if has {
|
||||
return ErrSourceAlreadyExist{source.Name}
|
||||
}
|
||||
|
||||
_, err = db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue