summaryrefslogtreecommitdiffstats
path: root/routers/web/admin/users.go
diff options
context:
space:
mode:
authorqwerty287 <80460567+qwerty287@users.noreply.github.com>2021-11-16 20:13:13 +0100
committerGitHub <noreply@github.com>2021-11-16 19:13:13 +0000
commit3be156f66a9682d698fe1191a7dd1016270873ab (patch)
tree55a17870cdfe1fa037a9b2d42836f1ae871debda /routers/web/admin/users.go
parentbbffcc3aecda040a40d49078e7141213bc8d78af (diff)
downloadgitea-3be156f66a9682d698fe1191a7dd1016270873ab.tar.gz
gitea-3be156f66a9682d698fe1191a7dd1016270873ab.zip
Allow admins to change user avatars (#17661)
Adds the avatar change panel to the edit user page (bottom) and allows admins to change it this way Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/web/admin/users.go')
-rw-r--r--routers/web/admin/users.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 8bafd1f19c..93e59893e9 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -401,3 +401,34 @@ func DeleteUser(ctx *context.Context) {
"redirect": setting.AppSubURL + "/admin/users",
})
}
+
+// AvatarPost response for change user's avatar request
+func AvatarPost(ctx *context.Context) {
+ u := prepareUserInfo(ctx)
+ if ctx.Written() {
+ return
+ }
+
+ form := web.GetForm(ctx).(*forms.AvatarForm)
+ if err := router_user_setting.UpdateAvatarSetting(ctx, form, u); err != nil {
+ ctx.Flash.Error(err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("settings.update_user_avatar_success"))
+ }
+
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10))
+}
+
+// DeleteAvatar render delete avatar page
+func DeleteAvatar(ctx *context.Context) {
+ u := prepareUserInfo(ctx)
+ if ctx.Written() {
+ return
+ }
+
+ if err := u.DeleteAvatar(); err != nil {
+ ctx.Flash.Error(err.Error())
+ }
+
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10))
+}