diff --git a/client.go b/client.go index 56a4935..5a9f3ce 100644 --- a/client.go +++ b/client.go @@ -127,6 +127,12 @@ func (c *Client) SelectVehicle(vin string) (*VehicleData, error) { } vinCheck(vin) + // Validate session before executing the request + if !c.validateSession() { + c.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) + return nil, errors.New(APP_ERRORS["SESSION_EXPIRED"]) + } + params := map[string]string{ "vin": vin, "_": timestamp()} @@ -319,6 +325,12 @@ func (c *Client) SubmitAuthCode(code string, permanent bool) error { // getContactMethods retrieves the available contact methods for two-factor authentication (2FA). // {"success":true,"dataName":"dataMap","data":{"userName":"a**x@savin.nyc","email":"t***a@savin.nyc"}} func (c *Client) getContactMethods() error { + // Validate session before executing the request + if !c.validateSession() { + c.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) + return errors.New(APP_ERRORS["SESSION_EXPIRED"]) + } + params := map[string]string{} reqUrl := MOBILE_API_VERSION + apiURLs["API_2FA_CONTACT"] resp, err := c.execute(POST, reqUrl, params, false) diff --git a/vehicle.go b/vehicle.go index edcfaab..724abca 100644 --- a/vehicle.go +++ b/vehicle.go @@ -451,7 +451,7 @@ func (v *Vehicle) GetClimatePresets() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -517,7 +517,7 @@ func (v *Vehicle) GetClimateQuickPresets() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -560,7 +560,7 @@ func (v *Vehicle) GetClimateUserPresets() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -612,7 +612,7 @@ func (v *Vehicle) GetVehicleStatus() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -680,7 +680,7 @@ func (v *Vehicle) GetVehicleCondition() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -737,7 +737,7 @@ func (v *Vehicle) GetVehicleHealth() error { } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) } @@ -802,7 +802,7 @@ func (v *Vehicle) executeServiceRequest(params map[string]string, reqUrl, pollin } // Validate session before executing the request - if v.client.validateSession() { + if !v.client.validateSession() { v.client.logger.Error(APP_ERRORS["SESSION_EXPIRED"]) return errors.New(APP_ERRORS["SESSION_EXPIRED"]) }