Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

Fixed a potential panic during account creation, closes #76

Dane Schneider1dc27af4e306
diff --git a/app/cli/auth/account.go b/app/cli/auth/account.go
index e7877550..0cbecbcf 100644
--- a/app/cli/auth/account.go
+++ b/app/cli/auth/account.go
@@ -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,
@@ -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
}