aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user/setting/profile.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-03-22 08:03:22 +0100
committerGitHub <noreply@github.com>2022-03-22 15:03:22 +0800
commit80fd25524e13dedbdc3527b32d008de152213a89 (patch)
tree63b2bfe4ffaf1dce12080cabdc2e845c8731a673 /routers/web/user/setting/profile.go
parent5495ba7660979973ba19e304786135da474e0e64 (diff)
downloadgitea-80fd25524e13dedbdc3527b32d008de152213a89.tar.gz
gitea-80fd25524e13dedbdc3527b32d008de152213a89.zip
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/user/setting/profile.go')
-rw-r--r--routers/web/user/setting/profile.go60
1 files changed, 30 insertions, 30 deletions
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index e77e02348c..72cbf33e5f 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -106,24 +106,24 @@ func ProfilePost(ctx *context.Context) {
return
}
- if len(form.Name) != 0 && ctx.User.Name != form.Name {
- log.Debug("Changing name for %s to %s", ctx.User.Name, form.Name)
- if err := HandleUsernameChange(ctx, ctx.User, form.Name); err != nil {
+ if len(form.Name) != 0 && ctx.Doer.Name != form.Name {
+ log.Debug("Changing name for %s to %s", ctx.Doer.Name, form.Name)
+ if err := HandleUsernameChange(ctx, ctx.Doer, form.Name); err != nil {
ctx.Redirect(setting.AppSubURL + "/user/settings")
return
}
- ctx.User.Name = form.Name
- ctx.User.LowerName = strings.ToLower(form.Name)
+ ctx.Doer.Name = form.Name
+ ctx.Doer.LowerName = strings.ToLower(form.Name)
}
- ctx.User.FullName = form.FullName
- ctx.User.KeepEmailPrivate = form.KeepEmailPrivate
- ctx.User.Website = form.Website
- ctx.User.Location = form.Location
- ctx.User.Description = form.Description
- ctx.User.KeepActivityPrivate = form.KeepActivityPrivate
- ctx.User.Visibility = form.Visibility
- if err := user_model.UpdateUserSetting(ctx.User); err != nil {
+ ctx.Doer.FullName = form.FullName
+ ctx.Doer.KeepEmailPrivate = form.KeepEmailPrivate
+ ctx.Doer.Website = form.Website
+ ctx.Doer.Location = form.Location
+ ctx.Doer.Description = form.Description
+ ctx.Doer.KeepActivityPrivate = form.KeepActivityPrivate
+ ctx.Doer.Visibility = form.Visibility
+ if err := user_model.UpdateUserSetting(ctx.Doer); err != nil {
if _, ok := err.(user_model.ErrEmailAlreadyUsed); ok {
ctx.Flash.Error(ctx.Tr("form.email_been_used"))
ctx.Redirect(setting.AppSubURL + "/user/settings")
@@ -134,10 +134,10 @@ func ProfilePost(ctx *context.Context) {
}
// Update the language to the one we just set
- middleware.SetLocaleCookie(ctx.Resp, ctx.User.Language, 0)
+ middleware.SetLocaleCookie(ctx.Resp, ctx.Doer.Language, 0)
- log.Trace("User settings updated: %s", ctx.User.Name)
- ctx.Flash.Success(i18n.Tr(ctx.User.Language, "settings.update_profile_success"))
+ log.Trace("User settings updated: %s", ctx.Doer.Name)
+ ctx.Flash.Success(i18n.Tr(ctx.Doer.Language, "settings.update_profile_success"))
ctx.Redirect(setting.AppSubURL + "/user/settings")
}
@@ -195,7 +195,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
// AvatarPost response for change user's avatar request
func AvatarPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.AvatarForm)
- if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil {
+ if err := UpdateAvatarSetting(ctx, form, ctx.Doer); err != nil {
ctx.Flash.Error(err.Error())
} else {
ctx.Flash.Success(ctx.Tr("settings.update_avatar_success"))
@@ -206,7 +206,7 @@ func AvatarPost(ctx *context.Context) {
// DeleteAvatar render delete avatar page
func DeleteAvatar(ctx *context.Context) {
- if err := user_service.DeleteAvatar(ctx.User); err != nil {
+ if err := user_service.DeleteAvatar(ctx.Doer); err != nil {
ctx.Flash.Error(err.Error())
}
@@ -223,7 +223,7 @@ func Organization(ctx *context.Context) {
PageSize: setting.UI.Admin.UserPagingNum,
Page: ctx.FormInt("page"),
},
- UserID: ctx.User.ID,
+ UserID: ctx.Doer.ID,
IncludePrivate: ctx.IsSigned,
}
@@ -268,7 +268,7 @@ func Repos(ctx *context.Context) {
adoptOrDelete := ctx.IsUserSiteAdmin() || (setting.Repository.AllowAdoptionOfUnadoptedRepositories && setting.Repository.AllowDeleteOfUnadoptedRepositories)
- ctxUser := ctx.User
+ ctxUser := ctx.Doer
count := 0
if adoptOrDelete {
@@ -360,7 +360,7 @@ func Appearance(ctx *context.Context) {
ctx.Data["PageIsSettingsAppearance"] = true
var hiddenCommentTypes *big.Int
- val, err := user_model.GetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes)
+ val, err := user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
if err != nil {
ctx.ServerError("GetUserSetting", err)
return
@@ -391,13 +391,13 @@ func UpdateUIThemePost(ctx *context.Context) {
return
}
- if err := user_model.UpdateUserTheme(ctx.User, form.Theme); err != nil {
+ if err := user_model.UpdateUserTheme(ctx.Doer, form.Theme); err != nil {
ctx.Flash.Error(ctx.Tr("settings.theme_update_error"))
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
return
}
- log.Trace("Update user theme: %s", ctx.User.Name)
+ log.Trace("Update user theme: %s", ctx.Doer.Name)
ctx.Flash.Success(ctx.Tr("settings.theme_update_success"))
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
}
@@ -414,31 +414,31 @@ func UpdateUserLang(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
return
}
- ctx.User.Language = form.Language
+ ctx.Doer.Language = form.Language
}
- if err := user_model.UpdateUserSetting(ctx.User); err != nil {
+ if err := user_model.UpdateUserSetting(ctx.Doer); err != nil {
ctx.ServerError("UpdateUserSetting", err)
return
}
// Update the language to the one we just set
- middleware.SetLocaleCookie(ctx.Resp, ctx.User.Language, 0)
+ middleware.SetLocaleCookie(ctx.Resp, ctx.Doer.Language, 0)
- log.Trace("User settings updated: %s", ctx.User.Name)
- ctx.Flash.Success(i18n.Tr(ctx.User.Language, "settings.update_language_success"))
+ log.Trace("User settings updated: %s", ctx.Doer.Name)
+ ctx.Flash.Success(i18n.Tr(ctx.Doer.Language, "settings.update_language_success"))
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
}
// UpdateUserHiddenComments update a user's shown comment types
func UpdateUserHiddenComments(ctx *context.Context) {
- err := user_model.SetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes, forms.UserHiddenCommentTypesFromRequest(ctx).String())
+ err := user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes, forms.UserHiddenCommentTypesFromRequest(ctx).String())
if err != nil {
ctx.ServerError("SetUserSetting", err)
return
}
- log.Trace("User settings updated: %s", ctx.User.Name)
+ log.Trace("User settings updated: %s", ctx.Doer.Name)
ctx.Flash.Success(ctx.Tr("settings.saved_successfully"))
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
}