MCPcopy Create free account
hub / github.com/cli/cli / logout

Method logout

internal/config/config.go:666–689  ·  view source on GitHub ↗
(hostname, username string)

Source from the content-addressed store, hash-verified

664}
665
666func (c *AuthConfig) logout(hostname, username string) error {
667 users := c.UsersForHost(hostname)
668
669 // Per-user keyring records are not covered by removing config keys.
670 _ = keyring.Delete(refreshableServiceName(hostname), username)
671 _ = keyring.Delete(keyringServiceName(hostname), username)
672
673 if len(users) < 2 {
674 _ = c.cfg.Remove([]string{hostsKey, hostname})
675 _ = keyring.Delete(keyringServiceName(hostname), "")
676 return ghConfig.Write(c.cfg)
677 }
678
679 _ = c.cfg.Remove([]string{hostsKey, hostname, usersKey, username})
680 activeUser, _ := c.ActiveUser(hostname)
681 if activeUser != username {
682 return ghConfig.Write(c.cfg)
683 }
684
685 switchUserIdx := slices.IndexFunc(users, func(n string) bool {
686 return n != username
687 })
688 return c.activateUser(hostname, users[switchUserIdx])
689}
690
691func (c *AuthConfig) activateUser(hostname, user string) error {
692 found, err := c.setActiveCredential(hostname, user)

Callers 2

LogoutMethod · 0.95
LogoutWithCredentialMethod · 0.95

Calls 8

UsersForHostMethod · 0.95
ActiveUserMethod · 0.95
activateUserMethod · 0.95
DeleteFunction · 0.92
refreshableServiceNameFunction · 0.85
keyringServiceNameFunction · 0.70
RemoveMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected