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

Method Login

internal/config/config.go:527–539  ·  view source on GitHub ↗

Login will set user, git protocol, and auth token for the given hostname. If the encrypt option is specified it will first try to store the auth token in encrypted storage and will fall back to the plain text config file.

(hostname, username, token, gitProtocol string, secureStorage bool)

Source from the content-addressed store, hash-verified

525// If the encrypt option is specified it will first try to store the auth token
526// in encrypted storage and will fall back to the plain text config file.
527func (c *AuthConfig) Login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) {
528 // Run under the shared refresh lock, like LoginRefreshable and Logout, so login serializes against an in-flight
529 // refresh and wins either ordering: a refresh that persists first is superseded by the credential stored here, and
530 // a refresh still waiting on the lock reloads afterwards, finds the refreshable record removed below, and bails
531 // without persisting. The lock is best effort, so login still proceeds when it is unavailable.
532 var insecureStorageUsed bool
533 err := c.withFreshConfigForRefresh(func(lockErr error) error {
534 var err error
535 insecureStorageUsed, err = c.login(hostname, username, token, gitProtocol, secureStorage)
536 return err
537 })
538 return insecureStorageUsed, err
539}
540
541func (c *AuthConfig) login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) {
542 // In this section we set up the users config

Callers

nothing calls this directly

Calls 2

loginMethod · 0.95

Tested by

no test coverage detected