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

Method purgeRefreshableForLogin

internal/config/refreshable.go:197–206  ·  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

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