mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add error return in some login failure cases (#30)
This commit is contained in:
parent
0fa829828f
commit
b70bf9902b
1 changed files with 7 additions and 0 deletions
|
|
@ -94,6 +94,13 @@ func LoginWithCredentials(user string, password string, locale LOCALE, client *h
|
||||||
|
|
||||||
if loginResp.StatusCode != http.StatusOK {
|
if loginResp.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("failed to auth with credentials: %s", loginResp.Status)
|
return nil, fmt.Errorf("failed to auth with credentials: %s", loginResp.Status)
|
||||||
|
} else {
|
||||||
|
var loginRespBody map[string]interface{}
|
||||||
|
json.NewDecoder(loginResp.Body).Decode(&loginRespBody)
|
||||||
|
|
||||||
|
if loginRespBody["error"].(bool) {
|
||||||
|
return nil, fmt.Errorf("an unexpected login error occoured: %s", loginRespBody["message"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginWithSessionID(sessionID, locale, client)
|
return LoginWithSessionID(sessionID, locale, client)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue