1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-10 19:48:19 +00:00

Fix 500 error if there is a name conflict when edit authentication source (#23832) (#23852)

Backport #23832 by @yp05327

Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
Giteabot
2023-03-31 12:53:25 -04:00
committed by GitHub
parent 503af4b807
commit 16bfe983c2
2 changed files with 12 additions and 3 deletions

View File

@@ -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
}