Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5eca0b57a6
commit
400831bf3c
2 files changed
+13
-1
No files matched your search
@@ -39,6 +39,7 @@ type Manager struct {
|
||||
saved *hub.Saved
|
||||
stop context.CancelFunc
|
||||
username string
|
||||
lastHub string // the hub last signed in to, for signing in again after signing out
|
||||
signin *signin
|
||||
}
|
||||
|
||||
@@ -106,6 +107,9 @@ func (m *Manager) status() status {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
s := status{Hub: m.DefaultHub}
|
||||
if m.lastHub != "" {
|
||||
s.Hub = m.lastHub
|
||||
}
|
||||
if m.saved != nil {
|
||||
s.SignedIn, s.Hub, s.Username = true, m.saved.URL, m.username
|
||||
}
|
||||
@@ -118,7 +122,7 @@ func (m *Manager) status() status {
|
||||
// SignIn starts signing in to a hub; the code to enter shows in the status, and the browser opens the page.
|
||||
func (m *Manager) SignIn(hubURL string) {
|
||||
if hubURL == "" {
|
||||
hubURL = m.DefaultHub
|
||||
hubURL = m.status().Hub
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
si := &signin{running: true, cancel: cancel}
|
||||
@@ -159,6 +163,9 @@ func (m *Manager) SignIn(hubURL string) {
|
||||
func (m *Manager) SignOut() {
|
||||
m.mu.Lock()
|
||||
c, stop := m.client, m.stop
|
||||
if m.saved != nil {
|
||||
m.lastHub = m.saved.URL
|
||||
}
|
||||
m.client, m.saved, m.stop, m.username, m.signin = nil, nil, nil, "", nil
|
||||
m.mu.Unlock()
|
||||
if c != nil {
|
||||
|
||||
@@ -109,6 +109,11 @@ func TestSignInAndOut(t *testing.T) {
|
||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||
t.Fatalf("hub.json: %v", err)
|
||||
}
|
||||
// Signing in again goes to the same hub.
|
||||
m.DefaultHub = "https://elsewhere.test"
|
||||
if s := ask(t, m, "GET", "/hub", ""); s.Hub != srv.URL {
|
||||
t.Fatalf("hub after signing out: %q", s.Hub)
|
||||
}
|
||||
|
||||
// Only https hubs (or this computer's); other requests to the proxy's address are refused.
|
||||
u, _ := url.Parse("http://" + Host + "/hub/signin")
|
||||
|
||||
Reference in new issue
Block a user