Add session validation checks before executing vehicle commands
Some checks failed
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Failing after 27s
Some checks failed
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Failing after 27s
This commit is contained in:
12
client.go
12
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)
|
||||
|
14
vehicle.go
14
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"])
|
||||
}
|
||||
|
Reference in New Issue
Block a user