Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix random avatar begin regenerated on every page refresh #1131

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ func (u *User) GenerateRandomAvatar() 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
u.Avatar = fmt.Sprintf("%d", u.ID)
if err = os.MkdirAll(filepath.Dir(u.CustomAvatarPath()), os.ModePerm); err != nil {
return fmt.Errorf("MkdirAll: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if u.Avatar == "" {
 u.Avatar = fmt.Sprintf("%d", u.ID)
}

maybe add this line is OK.

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will fix when u.Avatar is empty, then line 305 fw, err := os.Create(u.CustomAvatarPath()) will create an avatars file. This bug is reported by #1114.

Expand Down