control/controlclient: delete Status.Log{in,out}Finished

They were entirely redundant and 1:1 with the status field
so this turns them into methods instead.

Updates #cleanup
Updates #1909

Change-Id: I7d939750749edf7dae4c97566bbeb99f2f75adbc
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-30 11:09:36 -07:00
committed by Brad Fitzpatrick
parent 794650fe50
commit 7053e19562
6 changed files with 33 additions and 41 deletions

View File

@@ -969,7 +969,7 @@ func (b *LocalBackend) SetControlClientStatus(st controlclient.Status) {
b.blockEngineUpdates(false)
}
if st.LoginFinished != nil && wasBlocked {
if st.LoginFinished() && wasBlocked {
// Auth completed, unblock the engine
b.blockEngineUpdates(false)
b.authReconfig()
@@ -979,7 +979,7 @@ func (b *LocalBackend) SetControlClientStatus(st controlclient.Status) {
// Lock b once and do only the things that require locking.
b.mu.Lock()
if st.LogoutFinished != nil {
if st.LogoutFinished() {
if p := b.pm.CurrentPrefs(); !p.Persist().Valid() || p.Persist().UserProfile().LoginName() == "" {
b.mu.Unlock()
return
@@ -1017,7 +1017,7 @@ func (b *LocalBackend) SetControlClientStatus(st controlclient.Status) {
b.authURL = st.URL
b.authURLSticky = st.URL
}
if wasBlocked && st.LoginFinished != nil {
if wasBlocked && st.LoginFinished() {
// Interactive login finished successfully (URL visited).
// After an interactive login, the user always wants
// WantRunning.

View File

@@ -19,7 +19,6 @@ import (
"tailscale.com/tailcfg"
"tailscale.com/tsd"
"tailscale.com/tstest"
"tailscale.com/types/empty"
"tailscale.com/types/key"
"tailscale.com/types/logger"
"tailscale.com/types/logid"
@@ -171,9 +170,9 @@ func (cc *mockControl) send(err error, url string, loginFinished bool, nm *netma
Err: err,
}
if loginFinished {
s.LoginFinished = &empty.Message{}
s.SetStateForTest(controlclient.StateAuthenticated)
} else if url == "" && err == nil && nm == nil {
s.LogoutFinished = &empty.Message{}
s.SetStateForTest(controlclient.StateNotAuthenticated)
}
cc.opts.Observer.SetControlClientStatus(s)
}