diff options
| author | winter | 2024-12-16 20:42:26 +0000 |
|---|---|---|
| committer | winter | 2024-12-16 20:42:26 +0000 |
| commit | a33cc49a45053025e1977c3a1f6e4e7b5f8a264d (patch) | |
| tree | d1d742f8fa4fc80132c8d492e79f9a3f159c14d6 /Digitigrade/Model | |
| parent | 68c7e68b3f90fd980661774fdb2bb2d6140a34d0 (diff) | |
refresh tokens an hour before due
instead of literally doing it *as* they expire lol
Diffstat (limited to 'Digitigrade/Model')
| -rw-r--r-- | Digitigrade/Model/Instance.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php index e4b1ef1..7176fcd 100644 --- a/Digitigrade/Model/Instance.php +++ b/Digitigrade/Model/Instance.php @@ -97,7 +97,9 @@ class Instance extends FetchableModel { $this->auth->outboundToken = $data->token; $this->save(); - (new RefreshOutboundAuthToken($this->domain, new \DateTimeImmutable($data->expires)))->submit(); + // try to refresh it 1 hour before it expires, to leave some leeway + $refreshAt = (new \DateTimeImmutable($data->expires))->sub(new \DateInterval('PT1H')); + (new RefreshOutboundAuthToken($this->domain, $refreshAt))->submit(); } public function refreshOutboundAuthToken() { @@ -120,6 +122,8 @@ class Instance extends FetchableModel { $this->auth->outboundToken = $data->token; $this->save(); - (new RefreshOutboundAuthToken($this->domain, new \DateTimeImmutable($data->expires)))->submit(); + // try to refresh it again 1 hour before it expires, to leave some leeway + $refreshAt = (new \DateTimeImmutable($data->expires))->sub(new \DateInterval('PT1H')); + (new RefreshOutboundAuthToken($this->domain, $refreshAt))->submit(); } }
\ No newline at end of file |
