mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-25 14:45:20 +00:00
feat(user): use name for initals avatar, not username
For external auth providers, the username might be randomly generated, which results in a random initial - this is unexpected and confusing for users.
This commit is contained in:
@@ -143,7 +143,7 @@ func getAvatarForUser(u *user.User) (fullSizeAvatar *image.RGBA64, err error) {
|
||||
|
||||
if !exists {
|
||||
log.Debugf("Initials avatar for user %d not cached, creating...", u.ID)
|
||||
firstRune := []rune(strings.ToUpper(u.Username))[0]
|
||||
firstRune := []rune(strings.ToUpper(u.Name))[0]
|
||||
bg := avatarBgColors[int(u.ID)%len(avatarBgColors)] // Random color based on the user id
|
||||
|
||||
fullSizeAvatar, err = drawImage(firstRune, bg)
|
||||
|
||||
@@ -144,6 +144,10 @@ func ChangeUserAvatarProvider(c echo.Context) error {
|
||||
return handler.HandleHTTPError(err)
|
||||
}
|
||||
|
||||
if user.AvatarProvider == "initials" {
|
||||
avatar.FlushAllCaches(user)
|
||||
}
|
||||
|
||||
if err := s.Commit(); err != nil {
|
||||
_ = s.Rollback()
|
||||
return handler.HandleHTTPError(err)
|
||||
|
||||
Reference in New Issue
Block a user