summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/admin
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-01-26 06:54:04 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-26 19:54:04 +0800
commitd1b5498cc0128b463a04d9e216234d247b0761cd (patch)
tree84afcfff86093feb9584f51822706d14aafba3e5 /routers/api/v1/admin
parent067ae5d96ee24447789073e20af8b3a0b67a6a22 (diff)
downloadgitea-d1b5498cc0128b463a04d9e216234d247b0761cd.tar.gz
gitea-d1b5498cc0128b463a04d9e216234d247b0761cd.zip
Use handlers for API authorization (#723)
Diffstat (limited to 'routers/api/v1/admin')
-rw-r--r--routers/api/v1/admin/org_repo.go52
1 files changed, 0 insertions, 52 deletions
diff --git a/routers/api/v1/admin/org_repo.go b/routers/api/v1/admin/org_repo.go
deleted file mode 100644
index 8230c0acc4..0000000000
--- a/routers/api/v1/admin/org_repo.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2016 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package admin
-
-import (
- "code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/context"
-)
-
-// GetRepositoryByParams api for getting repository by orgnizition ID and repo name
-func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
- repo, err := models.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
- if err != nil {
- if models.IsErrRepoNotExist(err) {
- ctx.Status(404)
- } else {
- ctx.Error(500, "GetRepositoryByName", err)
- }
- return nil
- }
- return repo
-}
-
-// AddTeamRepository api for adding a repository to a team
-func AddTeamRepository(ctx *context.APIContext) {
- repo := GetRepositoryByParams(ctx)
- if ctx.Written() {
- return
- }
- if err := ctx.Org.Team.AddRepository(repo); err != nil {
- ctx.Error(500, "AddRepository", err)
- return
- }
-
- ctx.Status(204)
-}
-
-// RemoveTeamRepository api for removing a repository from a team
-func RemoveTeamRepository(ctx *context.APIContext) {
- repo := GetRepositoryByParams(ctx)
- if ctx.Written() {
- return
- }
- if err := ctx.Org.Team.RemoveRepository(repo.ID); err != nil {
- ctx.Error(500, "RemoveRepository", err)
- return
- }
-
- ctx.Status(204)
-}