diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2018-08-07 11:01:06 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-08-07 13:01:06 +0300 |
commit | 59b10e66f757441e8c74532f30740bf4a96e9ac1 (patch) | |
tree | c303efa6ce5bc98bfcec6a912fe181c72f6f0ead /routers/api | |
parent | c7a6ee5c0bd8dcceac76dcb2100e81395d57560a (diff) | |
download | gitea-59b10e66f757441e8c74532f30740bf4a96e9ac1.tar.gz gitea-59b10e66f757441e8c74532f30740bf4a96e9ac1.zip |
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
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/collaborators.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index 963b7c53ae..c52472b0f8 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -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 |