| 689 | } |
| 690 | |
| 691 | func (c *AuthConfig) activateUser(hostname, user string) error { |
| 692 | found, err := c.setActiveCredential(hostname, user) |
| 693 | if err != nil { |
| 694 | return err |
| 695 | } |
| 696 | if !found { |
| 697 | return fmt.Errorf("no token found for %s", user) |
| 698 | } |
| 699 | |
| 700 | // Then we'll update the active user for the host |
| 701 | c.cfg.Set([]string{hostsKey, hostname, userKey}, user) |
| 702 | |
| 703 | return ghConfig.Write(c.cfg) |
| 704 | } |
| 705 | |
| 706 | // setActiveCredential clears every host level active credential representation and copies the user's stored |
| 707 | // credential into the active slot, preserving its storage form. It neither sets the active user nor writes the |