fix(cli): always update server_url on login
Previously, `multica login` only saved server_url to config when it was empty. A stale value (e.g. from a prior session pointing at a different host) was never overwritten, causing subsequent API calls to hit the wrong server.
This commit is contained in:
parent
a10515fa74
commit
c3a9190016
1 changed files with 2 additions and 6 deletions
|
|
@ -202,9 +202,7 @@ func runAuthLoginBrowser(cmd *cobra.Command) error {
|
|||
// Save to config.
|
||||
cfg, _ := cli.LoadCLIConfig()
|
||||
cfg.Token = patResp.Token
|
||||
if cfg.ServerURL == "" {
|
||||
cfg.ServerURL = serverURL
|
||||
}
|
||||
cfg.ServerURL = serverURL
|
||||
if err := cli.SaveCLIConfig(cfg); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
|
@ -243,9 +241,7 @@ func runAuthLoginToken(cmd *cobra.Command) error {
|
|||
|
||||
cfg, _ := cli.LoadCLIConfig()
|
||||
cfg.Token = token
|
||||
if cfg.ServerURL == "" {
|
||||
cfg.ServerURL = serverURL
|
||||
}
|
||||
cfg.ServerURL = serverURL
|
||||
if err := cli.SaveCLIConfig(cfg); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue