aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/setting.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-11-22 10:22:53 -0500
committerUnknwon <joe2010xtmf@163.com>2014-11-22 10:22:53 -0500
commitdc53270da91c369cb00f992a600a1e014d555278 (patch)
tree459c48745c0b4a47ece248086f5edb77ca823260 /routers/user/setting.go
parent8ea7ba3afa686303f6597f6244bd9280f0b69a23 (diff)
downloadgitea-dc53270da91c369cb00f992a600a1e014d555278.tar.gz
gitea-dc53270da91c369cb00f992a600a1e014d555278.zip
Fix 653
Diffstat (limited to 'routers/user/setting.go')
-rw-r--r--routers/user/setting.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 7aeb349727..304ddd362b 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -89,9 +89,6 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
defer ctx.Redirect(setting.AppSubUrl + "/user/settings")
ctx.User.UseCustomAvatar = form.Enable
- if err := models.UpdateUser(ctx.User); err != nil {
- ctx.Flash.Error(err.Error())
- }
if form.Avatar != nil {
fr, err := form.Avatar.Open()
@@ -113,7 +110,19 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
ctx.Flash.Error(err.Error())
return
}
+ } else {
+ // In case no avatar at all.
+ if form.Enable && !com.IsFile(ctx.User.CustomAvatarPath()) {
+ ctx.Flash.Error(ctx.Tr("settings.no_custom_avatar_available"))
+ return
+ }
}
+
+ if err := models.UpdateUser(ctx.User); err != nil {
+ ctx.Flash.Error(err.Error())
+ return
+ }
+
ctx.Flash.Success(ctx.Tr("settings.update_avatar_success"))
}