| 640 | } |
| 641 | |
| 642 | func (c *AuthConfig) activateUser(hostname, user string) error { |
| 643 | found, err := c.setActiveCredential(hostname, user) |
| 644 | if err != nil { |
| 645 | return err |
| 646 | } |
| 647 | if !found { |
| 648 | return fmt.Errorf("no token found for %s", user) |
| 649 | } |
| 650 | |
| 651 | // Then we'll update the active user for the host |
| 652 | c.cfg.Set([]string{hostsKey, hostname, userKey}, user) |
| 653 | |
| 654 | return ghConfig.Write(c.cfg) |
| 655 | } |
| 656 | |
| 657 | // setActiveCredential clears every host level active credential representation and copies the user's stored |
| 658 | // credential into the active slot, preserving its storage form. It neither sets the active user nor writes the |