diff options
author | Unknwon <u@gogs.io> | 2016-03-25 18:04:02 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-25 18:04:02 -0400 |
commit | b1d41cfa603aee63711fbc23bb02fced5a4c54e3 (patch) | |
tree | dc79e8f9c8dec5ab324b27d10108667e7b4d9090 /routers/api/v1/admin | |
parent | 9dda9ef07c03000cb961a80e3c75459c58602009 (diff) | |
download | gitea-b1d41cfa603aee63711fbc23bb02fced5a4c54e3.tar.gz gitea-b1d41cfa603aee63711fbc23bb02fced5a4c54e3.zip |
#1692 add admin APIs to add/remove a user from teams
Diffstat (limited to 'routers/api/v1/admin')
-rw-r--r-- | routers/api/v1/admin/org_team.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/routers/api/v1/admin/org_team.go b/routers/api/v1/admin/org_team.go index 4c67b5743a..9b5411b12e 100644 --- a/routers/api/v1/admin/org_team.go +++ b/routers/api/v1/admin/org_team.go @@ -14,13 +14,8 @@ import ( ) func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { - org := user.GetUserByParamsName(ctx, ":orgname") - if ctx.Written() { - return - } - team := &models.Team{ - OrgID: org.Id, + OrgID: ctx.Org.Organization.Id, Name: form.Name, Description: form.Description, Authorize: models.ParseAccessMode(form.Permission), @@ -36,3 +31,30 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { ctx.JSON(201, convert.ToTeam(team)) } + +func AddTeamMember(ctx *context.APIContext) { + u := user.GetUserByParams(ctx) + if ctx.Written() { + return + } + if err := ctx.Org.Team.AddMember(u.Id); err != nil { + ctx.Error(500, "AddMember", err) + return + } + + ctx.Status(204) +} + +func RemoveTeamMember(ctx *context.APIContext) { + u := user.GetUserByParams(ctx) + if ctx.Written() { + return + } + + if err := ctx.Org.Team.RemoveMember(u.Id); err != nil { + ctx.Error(500, "RemoveMember", err) + return + } + + ctx.Status(204) +} |