# HG changeset patch # User Kim Alvefur # Date 1694420378 -7200 # Node ID f16edebb130539c89ab7c1c1862bea4434294ca8 # Parent 23f336cec20097179fc2a2d30bfef7d964e170da 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. diff -r 23f336cec200 -r f16edebb1305 mod_client_management/mod_client_management.lua --- 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; };