mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-20 13:41:41 +00:00
ipn/ipnlocal: update profile on server sent profile changes
We were not updating the LoginProfile.UserProfile when a netmap updated the UserProfile (e.g. when a node was tagged via the admin panel). Updates #713 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
976e88d430
commit
49b0ce8180
@ -3300,10 +3300,10 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
|||||||
if login == "" {
|
if login == "" {
|
||||||
login = "<missing-profile>"
|
login = "<missing-profile>"
|
||||||
}
|
}
|
||||||
if cp := b.pm.CurrentProfile(); cp.ID != "" && cp.UserProfile.ID == 0 {
|
if cp := b.pm.CurrentProfile(); cp.ID != "" && cp.UserProfile.ID != up.ID {
|
||||||
// Migration to profiles: we didn't use to persist
|
// If the current profile doesn't match the
|
||||||
// the UserProfile, so if we don't have one, fill it
|
// network map's user profile, then we need to
|
||||||
// in from the NetworkMap.
|
// update the persisted UserProfile to match.
|
||||||
prefs := b.pm.CurrentPrefs().AsStruct()
|
prefs := b.pm.CurrentPrefs().AsStruct()
|
||||||
prefs.Persist.UserProfile = up
|
prefs.Persist.UserProfile = up
|
||||||
b.pm.SetPrefs(prefs.View())
|
b.pm.SetPrefs(prefs.View())
|
||||||
|
@ -126,6 +126,7 @@ func (pm *profileManager) SetPrefs(prefsIn ipn.PrefsView) error {
|
|||||||
up.DisplayName = up.LoginName
|
up.DisplayName = up.LoginName
|
||||||
}
|
}
|
||||||
cp := pm.currentProfile
|
cp := pm.currentProfile
|
||||||
|
wasNamedWithLoginName := cp.Name == cp.UserProfile.LoginName
|
||||||
if pm.isNewProfile {
|
if pm.isNewProfile {
|
||||||
pm.isNewProfile = false
|
pm.isNewProfile = false
|
||||||
cp.ID, cp.Key = newUnusedID(pm.knownProfiles)
|
cp.ID, cp.Key = newUnusedID(pm.knownProfiles)
|
||||||
@ -135,6 +136,9 @@ func (pm *profileManager) SetPrefs(prefsIn ipn.PrefsView) error {
|
|||||||
} else {
|
} else {
|
||||||
cp.UserProfile = ps.UserProfile
|
cp.UserProfile = ps.UserProfile
|
||||||
}
|
}
|
||||||
|
if wasNamedWithLoginName {
|
||||||
|
cp.Name = ps.LoginName
|
||||||
|
}
|
||||||
pm.knownProfiles[cp.ID] = cp
|
pm.knownProfiles[cp.ID] = cp
|
||||||
if err := pm.writeKnownProfiles(); err != nil {
|
if err := pm.writeKnownProfiles(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user