Skip to content

Commit d949da6

Browse files
committed
[auth] Only write config on auth flow
1 parent a407ef1 commit d949da6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/auth.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ If your CLI is already authenticated this will return information about your ses
2626
}
2727

2828
auth := config.NewAuthenticator(cfg)
29-
if ok, err := auth.Check(); err != nil {
29+
ok, err := auth.Check()
30+
if err != nil {
3031
fmt.Println(err)
3132
os.Exit(1)
32-
} else if ok {
33+
}
34+
35+
if ok {
3336
fmt.Println("Authenticated")
34-
} else if !checkOnly {
35-
fmt.Println("Authentication required. Opening browser...")
36-
auth.Authenticate()
37-
} else {
37+
os.Exit(0)
38+
} else if checkOnly { // If we're only checking, exit with an error.
3839
fmt.Println("Invalid authentication")
40+
os.Exit(1)
3941
}
4042

43+
fmt.Println("Authentication required. Opening browser...")
44+
auth.Authenticate()
4145
if err := config.Store(cfg); err != nil {
4246
fmt.Println(err)
4347
}

0 commit comments

Comments
 (0)