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
62735cf07c
commit
f51bdeaec7
1 changed files with 7 additions and 0 deletions
|
|
@ -97,6 +97,13 @@ func LoginWithCredentials(user string, password string, locale LOCALE, client *h
|
|||
|
||||
if loginResp.StatusCode != http.StatusOK {
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue