forked from forgejo/forgejo
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:
parent
7cb1c1cf20
commit
c7a6ee5c0b
3 changed files with 109 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue