diff options
author | Unknwon <u@gogs.io> | 2015-09-03 06:17:33 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-03 06:17:33 -0400 |
commit | e5b105e513cb8bfe728c451525d1d9fd7d0979eb (patch) | |
tree | b9a29c91bf501ac3d2af7d4702c555cfbf295e39 /routers/api | |
parent | 8481adb255e2563cbd8dc5091e1efce8b370bcdb (diff) | |
download | gitea-e5b105e513cb8bfe728c451525d1d9fd7d0979eb.tar.gz gitea-e5b105e513cb8bfe728c451525d1d9fd7d0979eb.zip |
fix migrate API
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo.go | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go index 6e883a2084..07d836e5b3 100644 --- a/routers/api/v1/repo.go +++ b/routers/api/v1/repo.go @@ -192,23 +192,9 @@ func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) { } func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { - u, err := models.GetUserByName(ctx.Query("username")) - if err != nil { - if models.IsErrUserNotExist(err) { - ctx.HandleAPI(422, err) - } else { - ctx.HandleAPI(500, err) - } - return - } - if !u.ValidatePassword(ctx.Query("password")) { - ctx.HandleAPI(422, "Username or password is not correct.") - return - } - - ctxUser := u + ctxUser := ctx.User // Not equal means current user is an organization. - if form.Uid != u.Id { + if form.Uid != ctxUser.Id { org, err := models.GetUserByID(form.Uid) if err != nil { if models.IsErrUserNotExist(err) { @@ -228,7 +214,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { if ctxUser.IsOrganization() { // Check ownership of organization. - if !ctxUser.IsOwnedBy(u.Id) { + if !ctxUser.IsOwnedBy(ctx.User.Id) { ctx.HandleAPI(403, "Given user is not owner of organization.") return } |