forked from forgejo/forgejo
An inactive user shouldn't be able to be added as a collaborator (#4535)
* an inactive user shouldn't be able to be a collaborator * use translated error message * add active user check when adding a new collaborator via the api * fix translation text * added collaborator test * improvee testcases
This commit is contained in:
parent
c7a6ee5c0b
commit
59b10e66f7
4 changed files with 39 additions and 1 deletions
|
@ -5,6 +5,8 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
||||
|
@ -145,6 +147,11 @@ func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
|||
return
|
||||
}
|
||||
|
||||
if !collaborator.IsActive {
|
||||
ctx.Error(500, "InactiveCollaborator", errors.New("collaborator's account is inactive"))
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctx.Repo.Repository.AddCollaborator(collaborator); err != nil {
|
||||
ctx.Error(500, "AddCollaborator", err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue