We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1db2381 commit 66cead0Copy full SHA for 66cead0
models/user.go
@@ -521,7 +521,11 @@ func (u *User) UploadAvatar(data []byte) error {
521
}
522
523
u.UseCustomAvatar = true
524
- u.Avatar = fmt.Sprintf("%x", md5.Sum(data))
+ // Different users can upload same image as avatar
525
+ // If we prefix it with u.ID, it will be separated
526
+ // Otherwise, if any of the users delete his avatar
527
+ // Other users will lose their avatars too.
528
+ u.Avatar = fmt.Sprintf("%d-%x", u.ID, md5.Sum(data))
529
if err = updateUser(sess, u); err != nil {
530
return fmt.Errorf("updateUser: %v", err)
531
0 commit comments