From 80fd25524e13dedbdc3527b32d008de152213a89 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 22 Mar 2022 08:03:22 +0100 Subject: Renamed ctx.User to ctx.Doer. (#19161) Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang --- routers/api/v1/admin/adopt.go | 4 ++-- routers/api/v1/admin/cron.go | 2 +- routers/api/v1/admin/org.go | 2 +- routers/api/v1/admin/user.go | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'routers/api/v1/admin') diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go index db1754c8d0..3c39d7c2bc 100644 --- a/routers/api/v1/admin/adopt.go +++ b/routers/api/v1/admin/adopt.go @@ -110,7 +110,7 @@ func AdoptRepository(ctx *context.APIContext) { ctx.NotFound() return } - if _, err := repo_service.AdoptRepository(ctx.User, ctxUser, models.CreateRepoOptions{ + if _, err := repo_service.AdoptRepository(ctx.Doer, ctxUser, models.CreateRepoOptions{ Name: repoName, IsPrivate: true, }); err != nil { @@ -173,7 +173,7 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) { return } - if err := repo_service.DeleteUnadoptedRepository(ctx.User, ctxUser, repoName); err != nil { + if err := repo_service.DeleteUnadoptedRepository(ctx.Doer, ctxUser, repoName); err != nil { ctx.InternalServerError(err) return } diff --git a/routers/api/v1/admin/cron.go b/routers/api/v1/admin/cron.go index 1476872a90..0c4333b892 100644 --- a/routers/api/v1/admin/cron.go +++ b/routers/api/v1/admin/cron.go @@ -81,7 +81,7 @@ func PostCronTask(ctx *context.APIContext) { return } task.Run() - log.Trace("Cron Task %s started by admin(%s)", task.Name, ctx.User.Name) + log.Trace("Cron Task %s started by admin(%s)", task.Name, ctx.Doer.Name) ctx.Status(http.StatusNoContent) } diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index aaa27afb9e..4ebfe9863c 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -107,7 +107,7 @@ func GetAllOrgs(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) users, maxResults, err := user_model.SearchUsers(&user_model.SearchUserOptions{ - Actor: ctx.User, + Actor: ctx.Doer, Type: user_model.UserTypeOrganization, OrderBy: db.SearchOrderByAlphabetically, ListOptions: listOptions, diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 1d3854df9b..677950664d 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -128,13 +128,13 @@ func CreateUser(ctx *context.APIContext) { } return } - log.Trace("Account created by admin (%s): %s", ctx.User.Name, u.Name) + log.Trace("Account created by admin (%s): %s", ctx.Doer.Name, u.Name) // Send email notification. if form.SendNotify { mailer.SendRegisterNotifyMail(u) } - ctx.JSON(http.StatusCreated, convert.ToUser(u, ctx.User)) + ctx.JSON(http.StatusCreated, convert.ToUser(u, ctx.Doer)) } // EditUser api for modifying a user's information @@ -275,9 +275,9 @@ func EditUser(ctx *context.APIContext) { } return } - log.Trace("Account profile updated by admin (%s): %s", ctx.User.Name, u.Name) + log.Trace("Account profile updated by admin (%s): %s", ctx.Doer.Name, u.Name) - ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.User)) + ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.Doer)) } // DeleteUser api for deleting a user @@ -320,7 +320,7 @@ func DeleteUser(ctx *context.APIContext) { } return } - log.Trace("Account deleted by admin(%s): %s", ctx.User.Name, u.Name) + log.Trace("Account deleted by admin(%s): %s", ctx.Doer.Name, u.Name) ctx.Status(http.StatusNoContent) } @@ -401,7 +401,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) { } return } - log.Trace("Key deleted by admin(%s): %s", ctx.User.Name, u.Name) + log.Trace("Key deleted by admin(%s): %s", ctx.Doer.Name, u.Name) ctx.Status(http.StatusNoContent) } @@ -431,7 +431,7 @@ func GetAllUsers(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) users, maxResults, err := user_model.SearchUsers(&user_model.SearchUserOptions{ - Actor: ctx.User, + Actor: ctx.Doer, Type: user_model.UserTypeIndividual, OrderBy: db.SearchOrderByAlphabetically, ListOptions: listOptions, @@ -443,7 +443,7 @@ func GetAllUsers(ctx *context.APIContext) { results := make([]*api.User, len(users)) for i := range users { - results[i] = convert.ToUser(users[i], ctx.User) + results[i] = convert.ToUser(users[i], ctx.Doer) } ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) -- cgit v1.2.3