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

Method purgeRefreshableForLogin

internal/config/refreshable.go:196–205  ·  view source on GitHub ↗

purgeRefreshableForLogin removes any refreshable credential for the user during a non-refreshable login so the two credential forms cannot coexist. A surviving refreshable record outranks the freshly stored token during activation, so a removal that silently failed would let login report success whi

(hostname, username string)

Source from the content-addressed store, hash-verified

194// errRefreshableNotFound here, so the check stays silent exactly where a delete error would be spurious. Only a record
195// that genuinely survives removal resolves without error and is surfaced.
196func (c *AuthConfig) purgeRefreshableForLogin(hostname, username string) error {
197 // Best-effort removal in both stores, matching loginRefreshable's symmetric cleanup.
198 _ = c.cfg.Remove(refreshablePath(hostname, username))
199 _ = keyringDelete(refreshableServiceName(hostname), username)
200
201 if _, _, err := c.refreshableForUser(hostname, username); err == nil {
202 return errors.New("could not remove the existing refreshable credential, which would shadow this login")
203 }
204 return nil
205}
206
207// purgeNonExpiringForRefreshableLogin removes any non-expiring credential for the user during a refreshable login so
208// the two credential forms cannot coexist. The ordinary keyring is now resolved before the refreshable credential, so

Callers 1

loginMethod · 0.95

Calls 4

refreshableForUserMethod · 0.95
refreshablePathFunction · 0.85
refreshableServiceNameFunction · 0.85
RemoveMethod · 0.65

Tested by

no test coverage detected