From 59b10e66f757441e8c74532f30740bf4a96e9ac1 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 7 Aug 2018 11:01:06 +0100 Subject: 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 --- routers/api/v1/repo/collaborators.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'routers/api') 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 -- cgit v1.2.3