mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
profile: use name or fallback for profile page
This commit is contained in:
@@ -120,8 +120,8 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
|
|||||||
|
|
||||||
if c.IsSignedIn {
|
if c.IsSignedIn {
|
||||||
profileNode := &dtos.NavLink{
|
profileNode := &dtos.NavLink{
|
||||||
Text: c.SignedInUser.Login,
|
Text: c.SignedInUser.NameOrFallback(),
|
||||||
SubTitle: c.SignedInUser.Name,
|
SubTitle: c.SignedInUser.Login,
|
||||||
Id: "profile",
|
Id: "profile",
|
||||||
Img: data.User.GravatarUrl,
|
Img: data.User.GravatarUrl,
|
||||||
Url: setting.AppSubUrl + "/profile",
|
Url: setting.AppSubUrl + "/profile",
|
||||||
|
|||||||
@@ -170,6 +170,16 @@ func (u *SignedInUser) ShouldUpdateLastSeenAt() bool {
|
|||||||
return u.UserId > 0 && time.Since(u.LastSeenAt) > time.Minute*5
|
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 {
|
type UpdateUserLastSeenAtCommand struct {
|
||||||
UserId int64
|
UserId int64
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user