From d347e8286bae38b3949f6e0f58d8ab8632cd9c0e Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 23 Feb 2025 17:01:01 -0800 Subject: Track token expiration Force reauthentication after the token expires. --- controllers/auth.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'controllers/auth.php') diff --git a/controllers/auth.php b/controllers/auth.php index 9dcc81d..50dbc02 100644 --- a/controllers/auth.php +++ b/controllers/auth.php @@ -175,6 +175,10 @@ $app->get('/auth/callback', function() use($app) { $user->token_endpoint = $tokenEndpoint; $user->micropub_endpoint = $micropubEndpoint; $user->micropub_access_token = $token['response']['access_token']; + if(is_numeric($token['response']['expires_in'])) { + $expiration = time() + $token['response']['expires_in']; + $user->micropub_token_expiration = date('Y-m-d H:i:s', $expiration); + } $user->micropub_scope = $token['response']['scope']; $user->micropub_response = $token['raw_response']; $user->save(); @@ -236,6 +240,7 @@ $app->post('/auth/reset', function() use($app) { $user->micropub_media_endpoint = ''; $user->micropub_scope = ''; $user->micropub_access_token = ''; + $user->micropub_token_expiration = ''; $user->syndication_targets = ''; $user->supported_post_types = ''; $user->save(); -- cgit v1.2.3