Skip to content

Commit 011f128

Browse files
sdwolfzbkcsoft
authored andcommitted
Fixes missing avatars in offline mode (#3471)
Signed-off-by: Codruț Constantin Gușoi <[email protected]>
1 parent 9720f90 commit 011f128

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

models/user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ func (u *User) generateRandomAvatar(e Engine) error {
299299
}
300300
// NOTICE for random avatar, it still uses id as avatar name, but custom avatar use md5
301301
// since random image is not a user's photo, there is no security for enumable
302-
u.Avatar = fmt.Sprintf("%d", u.ID)
302+
if u.Avatar == "" {
303+
u.Avatar = fmt.Sprintf("%d", u.ID)
304+
}
303305
if err = os.MkdirAll(filepath.Dir(u.CustomAvatarPath()), os.ModePerm); err != nil {
304306
return fmt.Errorf("MkdirAll: %v", err)
305307
}

0 commit comments

Comments
 (0)