Skip to content

Commit

Permalink
Fixed a potential panic during account creation, closes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
danenania committed May 16, 2024
1 parent ffcb82c commit 1dc27af
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions app/cli/auth/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,7 @@ func signIn(email, pin, host string) error {
return fmt.Errorf("error signing in: %v", apiErr.Msg)
}

orgId, orgName, err := resolveOrgAuth(res.Orgs)

if err != nil {
return fmt.Errorf("error resolving org: %v", err)
}

err = setAuth(&types.ClientAuth{
err := setAuth(&types.ClientAuth{
ClientAccount: types.ClientAccount{
Email: res.Email,
UserId: res.UserId,
Expand All @@ -230,14 +224,27 @@ func signIn(email, pin, host string) error {
IsCloud: host == "",
Host: host,
},
OrgId: orgId,
OrgName: orgName,
})

if err != nil {
return fmt.Errorf("error setting auth: %v", err)
}

orgId, orgName, err := resolveOrgAuth(res.Orgs)

if err != nil {
return fmt.Errorf("error resolving org: %v", err)
}

Current.OrgId = orgId
Current.OrgName = orgName

err = writeCurrentAuth()

if err != nil {
return fmt.Errorf("error writing auth: %v", err)
}

return nil
}

Expand Down

0 comments on commit 1dc27af

Please sign in to comment.