summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/admin/org_team.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/admin/org_team.go')
-rw-r--r--routers/api/v1/admin/org_team.go34
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)
+}