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)
| 501 | // If the encrypt option is specified it will first try to store the auth token |
| 502 | // in encrypted storage and will fall back to the plain text config file. |
| 503 | func (c *AuthConfig) Login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) { |
| 504 | // Run under the shared refresh lock, like LoginRefreshable and Logout, so login serializes against an in-flight |
| 505 | // refresh and wins either ordering: a refresh that persists first is superseded by the credential stored here, and |
| 506 | // a refresh still waiting on the lock reloads afterwards, finds the refreshable record removed below, and bails |
| 507 | // without persisting. The lock is best effort, so login still proceeds when it is unavailable. |
| 508 | var insecureStorageUsed bool |
| 509 | err := c.withFreshConfigForRefresh(func(lockErr error) error { |
| 510 | var err error |
| 511 | insecureStorageUsed, err = c.login(hostname, username, token, gitProtocol, secureStorage) |
| 512 | return err |
| 513 | }) |
| 514 | return insecureStorageUsed, err |
| 515 | } |
| 516 | |
| 517 | func (c *AuthConfig) login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) { |
| 518 | // In this section we set up the users config |
nothing calls this directly
no test coverage detected