completeLogin sets the host git protocol, ensures the user entry is persisted, and activates the user. It is shared by Login and LoginRefreshable once the credential has been stored.
(hostname, username, gitProtocol string)
| 546 | // completeLogin sets the host git protocol, ensures the user entry is persisted, and activates the user. It is shared |
| 547 | // by Login and LoginRefreshable once the credential has been stored. |
| 548 | func (c *AuthConfig) completeLogin(hostname, username, gitProtocol string) error { |
| 549 | if gitProtocol != "" { |
| 550 | // Set the host level git protocol |
| 551 | // Although it might be expected that this is handled by switch, git protocol |
| 552 | // is currently a host level config and not a user level config, so any change |
| 553 | // will overwrite the protocol for all users on the host. |
| 554 | c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol) |
| 555 | } |
| 556 | |
| 557 | // Create the username key with an empty value so it will be |
| 558 | // written even when there are no keys set under it. |
| 559 | if _, getErr := c.cfg.Get([]string{hostsKey, hostname, usersKey, username}); getErr != nil { |
| 560 | c.cfg.Set([]string{hostsKey, hostname, usersKey, username}, "") |
| 561 | } |
| 562 | |
| 563 | // Then we activate the new user |
| 564 | return c.activateUser(hostname, username) |
| 565 | } |
| 566 | |
| 567 | func (c *AuthConfig) SwitchUser(hostname, user string) error { |
| 568 | previouslyActiveUser, err := c.ActiveUser(hostname) |
no test coverage detected