diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2018-08-07 02:59:42 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-08-07 09:59:42 +0800 |
commit | c7a6ee5c0bd8dcceac76dcb2100e81395d57560a (patch) | |
tree | 711472c36381aec2956eea30fb46415027816554 /routers/repo/setting.go | |
parent | 7cb1c1cf20f1a07d98b78c2ba56c3b50777701a5 (diff) | |
download | gitea-c7a6ee5c0bd8dcceac76dcb2100e81395d57560a.tar.gz gitea-c7a6ee5c0bd8dcceac76dcb2100e81395d57560a.zip |
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
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r-- | routers/repo/setting.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index fa3bd434d5..835ba0a751 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -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 |