diff --git a/pkg/api/index.go b/pkg/api/index.go index c7a434cd2b7..6629c2f5ca5 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -120,8 +120,8 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { if c.IsSignedIn { profileNode := &dtos.NavLink{ - Text: c.SignedInUser.Login, - SubTitle: c.SignedInUser.Name, + Text: c.SignedInUser.NameOrFallback(), + SubTitle: c.SignedInUser.Login, Id: "profile", Img: data.User.GravatarUrl, Url: setting.AppSubUrl + "/profile", diff --git a/pkg/models/user.go b/pkg/models/user.go index c6804a62514..a8819711d67 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -170,6 +170,16 @@ func (u *SignedInUser) ShouldUpdateLastSeenAt() bool { return u.UserId > 0 && time.Since(u.LastSeenAt) > time.Minute*5 } +func (u *SignedInUser) NameOrFallback() string { + if u.Name != "" { + return u.Name + } else if u.Login != "" { + return u.Login + } else { + return u.Email + } +} + type UpdateUserLastSeenAtCommand struct { UserId int64 }