From d2ad4dec63cb3ee94b5ba997aa2e2514abc53096 Mon Sep 17 00:00:00 2001 From: Paweł Bogusławski Date: Fri, 23 Oct 2020 19:55:10 +0200 Subject: Avatar autogeneration fixed (#13233) This mod fixes problem with initial avatar autogeneration and avatar autogneration after deleting previous avatar. Related: https://github.com/go-gitea/gitea/issues/13159 Fixes: 80a6b0f5bce15a641fc75f5f1ef6e42ef54424bc Author-Change-Id: IB#1105243 --- routers/user/setting/profile.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'routers/user') diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go index 1cb00aa77f..edb78031f2 100644 --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -121,7 +121,11 @@ func ProfilePost(ctx *context.Context, form auth.UpdateProfileForm) { func UpdateAvatarSetting(ctx *context.Context, form auth.AvatarForm, ctxUser *models.User) error { ctxUser.UseCustomAvatar = form.Source == auth.AvatarLocal if len(form.Gravatar) > 0 { - ctxUser.Avatar = base.EncodeMD5(form.Gravatar) + if form.Avatar != nil { + ctxUser.Avatar = base.EncodeMD5(form.Gravatar) + } else { + ctxUser.Avatar = "" + } ctxUser.AvatarEmail = form.Gravatar } -- cgit v1.2.3