Add error return in some login failure cases (#30)

This commit is contained in:
bytedream 2022-05-16 20:03:52 +02:00
parent 62735cf07c
commit f51bdeaec7

View file

@ -97,6 +97,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)