Changeset

5668:f16edebb1305

mod_client_management: Show grant expiry in shell command I want to know when my OAuth2 grant expires and that it really is extended by refreshing.
author Kim Alvefur <zash@zash.se>
date Mon, 11 Sep 2023 10:19:38 +0200
parents 5667:23f336cec200
children 5669:d67980d9e12d
files mod_client_management/mod_client_management.lua
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_client_management/mod_client_management.lua	Sat Sep 09 22:51:25 2023 +0200
+++ b/mod_client_management/mod_client_management.lua	Mon Sep 11 10:19:38 2023 +0200
@@ -252,6 +252,7 @@
 				type = "access";
 				first_seen = grant.created;
 				last_seen = grant.accessed;
+				expires = grant.expires;
 				active = {
 					grant = grant;
 				};
@@ -438,9 +439,11 @@
 		end
 
 		local function date_or_time(last_seen)
-			return last_seen and os.date(os.difftime(os.time(), last_seen) >= 86400 and "%Y-%m-%d" or "%H:%M:%S", last_seen);
+			return last_seen and os.date(math.abs(os.difftime(os.time(), last_seen)) >= 86400 and "%Y-%m-%d" or "%H:%M:%S", last_seen);
 		end
 
+		local date_or_time_width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S"));
+
 		local colspec = {
 			{ title = "ID"; key = "id"; width = "1p" };
 			{
@@ -452,14 +455,21 @@
 			{
 				title = "First seen";
 				key = "first_seen";
-				width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S"));
+				width = date_or_time_width;
 				align = "right";
 				mapper = date_or_time;
 			};
 			{
 				title = "Last seen";
 				key = "last_seen";
-				width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S"));
+				width = date_or_time_width;
+				align = "right";
+				mapper = date_or_time;
+			};
+			{
+				title = "Expires";
+				key = "expires";
+				width = date_or_time_width;
 				align = "right";
 				mapper = date_or_time;
 			};