From 4f9c5981a923687a803a3711fe33cd211584f36b Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 23 Feb 2017 11:39:09 -0500 Subject: refactoring: modules/auth/*_form.go -> modules/form --- routers/api/v1/api.go | 4 ++-- routers/api/v1/repo/repo.go | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'routers/api/v1') diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index d883d6c0..df5fb5c3 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -13,8 +13,8 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/context" + "github.com/gogits/gogs/modules/form" "github.com/gogits/gogs/routers/api/v1/admin" "github.com/gogits/gogs/routers/api/v1/misc" "github.com/gogits/gogs/routers/api/v1/org" @@ -237,7 +237,7 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Group("/repos", func() { - m.Post("/migrate", bind(auth.MigrateRepoForm{}), repo.Migrate) + m.Post("/migrate", bind(form.MigrateRepo{}), repo.Migrate) m.Combo("/:username/:reponame").Get(repo.Get). Delete(repo.Delete) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 1fd0af3d..147b980d 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -12,8 +12,8 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/context" + "github.com/gogits/gogs/modules/form" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers/api/v1/convert" ) @@ -206,12 +206,12 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { } // https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate -func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { +func Migrate(ctx *context.APIContext, f form.MigrateRepo) { ctxUser := ctx.User // Not equal means context user is an organization, // or is another user/organization if current user is admin. - if form.Uid != ctxUser.ID { - org, err := models.GetUserByID(form.Uid) + if f.Uid != ctxUser.ID { + org, err := models.GetUserByID(f.Uid) if err != nil { if models.IsErrUserNotExist(err) { ctx.Error(422, "", err) @@ -236,7 +236,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { } } - remoteAddr, err := form.ParseRemoteAddr(ctx.User) + remoteAddr, err := f.ParseRemoteAddr(ctx.User) if err != nil { if models.IsErrInvalidCloneAddr(err) { addrErr := err.(models.ErrInvalidCloneAddr) @@ -257,10 +257,10 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { } repo, err := models.MigrateRepository(ctxUser, models.MigrateRepoOptions{ - Name: form.RepoName, - Description: form.Description, - IsPrivate: form.Private || setting.Repository.ForcePrivate, - IsMirror: form.Mirror, + Name: f.RepoName, + Description: f.Description, + IsPrivate: f.Private || setting.Repository.ForcePrivate, + IsMirror: f.Mirror, RemoteAddr: remoteAddr, }) if err != nil { @@ -273,7 +273,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { return } - log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) + log.Trace("Repository migrated: %s/%s", ctxUser.Name, f.RepoName) ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true})) } -- cgit v1.2.3