diff --git a/hscontrol/mapper/mapper.go b/hscontrol/mapper/mapper.go index d7a6cfc..7342041 100644 --- a/hscontrol/mapper/mapper.go +++ b/hscontrol/mapper/mapper.go @@ -94,7 +94,6 @@ func (m *Mapper) String() string { func generateUserProfiles( node *types.Node, peers types.Nodes, - baseDomain string, ) []tailcfg.UserProfile { userMap := make(map[string]types.User) userMap[node.User.Name] = node.User @@ -104,18 +103,8 @@ func generateUserProfiles( var profiles []tailcfg.UserProfile for _, user := range userMap { - displayName := user.Name - - if baseDomain != "" { - displayName = fmt.Sprintf("%s@%s", user.Name, baseDomain) - } - profiles = append(profiles, - tailcfg.UserProfile{ - ID: tailcfg.UserID(user.ID), - LoginName: user.Name, - DisplayName: displayName, - }) + user.TailscaleUserProfile()) } return profiles @@ -569,7 +558,7 @@ func appendPeerChanges( changed = policy.FilterNodesByACL(node, changed, packetFilter) } - profiles := generateUserProfiles(node, changed, cfg.BaseDomain) + profiles := generateUserProfiles(node, changed) dnsConfig := generateDNSConfig( cfg, diff --git a/hscontrol/mapper/mapper_test.go b/hscontrol/mapper/mapper_test.go index be48c6f..0484fc0 100644 --- a/hscontrol/mapper/mapper_test.go +++ b/hscontrol/mapper/mapper_test.go @@ -43,7 +43,6 @@ func (s *Suite) TestGetMapResponseUserProfiles(c *check.C) { types.Nodes{ nodeInShared2, nodeInShared3, node2InShared1, }, - "", ) c.Assert(len(userProfiles), check.Equals, 3) diff --git a/hscontrol/types/users.go b/hscontrol/types/users.go index 0b8324f..63e73a5 100644 --- a/hscontrol/types/users.go +++ b/hscontrol/types/users.go @@ -19,32 +19,46 @@ type User struct { Name string `gorm:"unique"` } -func (n *User) TailscaleUser() *tailcfg.User { +// TODO(kradalby): See if we can fill in Gravatar here +func (u *User) profilePicURL() string { + return "" +} + +func (u *User) TailscaleUser() *tailcfg.User { user := tailcfg.User{ - ID: tailcfg.UserID(n.ID), - LoginName: n.Name, - DisplayName: n.Name, - // TODO(kradalby): See if we can fill in Gravatar here - ProfilePicURL: "", + ID: tailcfg.UserID(u.ID), + LoginName: u.Name, + DisplayName: u.Name, + ProfilePicURL: u.profilePicURL(), Logins: []tailcfg.LoginID{}, - Created: n.CreatedAt, + Created: u.CreatedAt, } return &user } -func (n *User) TailscaleLogin() *tailcfg.Login { +func (u *User) TailscaleLogin() *tailcfg.Login { login := tailcfg.Login{ - ID: tailcfg.LoginID(n.ID), - LoginName: n.Name, - DisplayName: n.Name, - // TODO(kradalby): See if we can fill in Gravatar here - ProfilePicURL: "", + ID: tailcfg.LoginID(u.ID), + // TODO(kradalby): this should reflect registration method. + Provider: "", + LoginName: u.Name, + DisplayName: u.Name, + ProfilePicURL: u.profilePicURL(), } return &login } +func (u *User) TailscaleUserProfile() tailcfg.UserProfile { + return tailcfg.UserProfile{ + ID: tailcfg.UserID(u.ID), + LoginName: u.Name, + DisplayName: u.Name, + ProfilePicURL: u.profilePicURL(), + } +} + func (n *User) Proto() *v1.User { return &v1.User{ Id: strconv.FormatUint(uint64(n.ID), util.Base10),