aboutsummaryrefslogtreecommitdiffstats
path: root/models/user_avatar.go
diff options
context:
space:
mode:
authorPaweł Bogusławski <pawel.boguslawski@ib.pl>2020-10-23 19:55:10 +0200
committerGitHub <noreply@github.com>2020-10-23 20:55:10 +0300
commitd2ad4dec63cb3ee94b5ba997aa2e2514abc53096 (patch)
tree5c1c9fa0cd054790b7a23f17bcaad34899417e49 /models/user_avatar.go
parente4d953354378d7ed5de6127e5133f22dff1d5fae (diff)
downloadgitea-d2ad4dec63cb3ee94b5ba997aa2e2514abc53096.tar.gz
gitea-d2ad4dec63cb3ee94b5ba997aa2e2514abc53096.zip
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
Diffstat (limited to 'models/user_avatar.go')
-rw-r--r--models/user_avatar.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/models/user_avatar.go b/models/user_avatar.go
index 0a03ca7707..2f9db5c2e2 100644
--- a/models/user_avatar.go
+++ b/models/user_avatar.go
@@ -39,10 +39,9 @@ func (u *User) generateRandomAvatar(e Engine) error {
if err != nil {
return fmt.Errorf("RandomImage: %v", err)
}
- // NOTICE for random avatar, it still uses id as avatar name, but custom avatar use md5
- // since random image is not a user's photo, there is no security for enumable
+
if u.Avatar == "" {
- u.Avatar = fmt.Sprintf("%d", u.ID)
+ u.Avatar = base.HashEmail(u.AvatarEmail)
}
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {