Add session validation checks before executing vehicle commands
Some checks failed
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Failing after 27s

This commit is contained in:
2025-07-08 16:32:45 -04:00
parent 30bd0bde44
commit e8a1d8f54e
2 changed files with 19 additions and 7 deletions

View File

@ -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)