Skip to content

Commit

Permalink
More, more
Browse files Browse the repository at this point in the history
  • Loading branch information
elffjs committed Jul 18, 2023
1 parent 3bce440 commit 36fa129
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/controllers/synthetic_devices_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func (sdc *SyntheticDevicesController) ReAuthenticate(c *fiber.Ctx) error {
return err
}

oldUDAI, err = models.FindUserDeviceAPIIntegration(c.Context(), sdc.DBS().Reader, sd.R.VehicleToken.UserDeviceID.String, i.Id)
oldUDAI, err := models.FindUserDeviceAPIIntegration(c.Context(), sdc.DBS().Reader, sd.R.VehicleToken.UserDeviceID.String, i.Id)
if err != nil {
return err
}
Expand All @@ -704,10 +704,21 @@ func (sdc *SyntheticDevicesController) ReAuthenticate(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, "Couldn't parse request.")
}

newUdai, err := sdc.generateUDAI(c.Context(), req.Credentials, sd.R.VehicleToken.UserDeviceID.String, i)
newUDAI, err := sdc.generateUDAI(c.Context(), req.Credentials, sd.R.VehicleToken.UserDeviceID.String, i)
if err != nil {
return err
}

switch i.Vendor {
case constants.SmartCarVendor:
sdc.smartcarTask.StopPoll(oldUDAI)

newUDAI.Update(c.Context(), sdc.DBS().Writer, boil.Infer())
case constants.TeslaVendor:
sdc.teslaTask.StopPoll(oldUDAI)
sdc.teslaTask.StartPoll(newUDAI)
newUDAI.Update(c.Context(), sdc.DBS().Writer, boil.Infer())
}

return nil
}

0 comments on commit 36fa129

Please sign in to comment.