1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Don't fail silently if trying to add a collaborator twice (#4533)

* don't fail silently if trying to add a collaborator twice

* fix translation text

* added collaborator test

* improvee testcases

* Added tests to make sure a collaborator cannot be added twice
This commit is contained in:
Lanre Adelowo
2018-08-07 02:59:42 +01:00
committed by Lunny Xiao
parent 7cb1c1cf20
commit c7a6ee5c0b
3 changed files with 109 additions and 0 deletions

View File

@@ -401,6 +401,12 @@ func CollaborationPost(ctx *context.Context) {
}
}
if got, err := ctx.Repo.Repository.IsCollaborator(u.ID); err == nil && got {
ctx.Flash.Error(ctx.Tr("repo.settings.add_collaborator_duplicate"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return
}
if err = ctx.Repo.Repository.AddCollaborator(u); err != nil {
ctx.ServerError("AddCollaborator", err)
return