mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
handle session queries not being valid
This commit is contained in:
parent
48595f25fa
commit
037df1d16f
1 changed files with 9 additions and 0 deletions
|
|
@ -70,6 +70,10 @@ func LoginWithCredentials(user string, password string, locale LOCALE, client *h
|
||||||
}
|
}
|
||||||
defer sessResp.Body.Close()
|
defer sessResp.Body.Close()
|
||||||
|
|
||||||
|
if sessResp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("Failed to start session: %s", sessResp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
var data map[string]interface{}
|
var data map[string]interface{}
|
||||||
body, _ := io.ReadAll(sessResp.Body)
|
body, _ := io.ReadAll(sessResp.Body)
|
||||||
json.Unmarshal(body, &data)
|
json.Unmarshal(body, &data)
|
||||||
|
|
@ -109,6 +113,11 @@ func LoginWithSessionID(sessionID string, locale LOCALE, client *http.Client) (*
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("Failed to start session: %s", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
json.NewDecoder(resp.Body).Decode(&jsonBody)
|
json.NewDecoder(resp.Body).Decode(&jsonBody)
|
||||||
if _, ok := jsonBody["message"]; ok {
|
if _, ok := jsonBody["message"]; ok {
|
||||||
return nil, errors.New("invalid session id")
|
return nil, errors.New("invalid session id")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue