Mercurial > prosody-modules
comparison mod_client_management/mod_client_management.lua @ 5645: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 | 1571c280aaef |
| children | c69320fc438b |
comparison
equal
deleted
inserted
replaced
| 5644:23f336cec200 | 5645:f16edebb1305 |
|---|---|
| 250 table.insert(active_clients, { | 250 table.insert(active_clients, { |
| 251 id = "grant/"..grant_id; | 251 id = "grant/"..grant_id; |
| 252 type = "access"; | 252 type = "access"; |
| 253 first_seen = grant.created; | 253 first_seen = grant.created; |
| 254 last_seen = grant.accessed; | 254 last_seen = grant.accessed; |
| 255 expires = grant.expires; | |
| 255 active = { | 256 active = { |
| 256 grant = grant; | 257 grant = grant; |
| 257 }; | 258 }; |
| 258 user_agent = get_user_agent(nil, grant); | 259 user_agent = get_user_agent(nil, grant); |
| 259 }); | 260 }); |
| 436 if not clients or #clients == 0 then | 437 if not clients or #clients == 0 then |
| 437 return true, "No clients associated with this account"; | 438 return true, "No clients associated with this account"; |
| 438 end | 439 end |
| 439 | 440 |
| 440 local function date_or_time(last_seen) | 441 local function date_or_time(last_seen) |
| 441 return last_seen and os.date(os.difftime(os.time(), last_seen) >= 86400 and "%Y-%m-%d" or "%H:%M:%S", last_seen); | 442 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); |
| 442 end | 443 end |
| 444 | |
| 445 local date_or_time_width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); | |
| 443 | 446 |
| 444 local colspec = { | 447 local colspec = { |
| 445 { title = "ID"; key = "id"; width = "1p" }; | 448 { title = "ID"; key = "id"; width = "1p" }; |
| 446 { | 449 { |
| 447 title = "Software"; | 450 title = "Software"; |
| 450 mapper = user_agent_tostring; | 453 mapper = user_agent_tostring; |
| 451 }; | 454 }; |
| 452 { | 455 { |
| 453 title = "First seen"; | 456 title = "First seen"; |
| 454 key = "first_seen"; | 457 key = "first_seen"; |
| 455 width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); | 458 width = date_or_time_width; |
| 456 align = "right"; | 459 align = "right"; |
| 457 mapper = date_or_time; | 460 mapper = date_or_time; |
| 458 }; | 461 }; |
| 459 { | 462 { |
| 460 title = "Last seen"; | 463 title = "Last seen"; |
| 461 key = "last_seen"; | 464 key = "last_seen"; |
| 462 width = math.max(#os.date("%Y-%m-%d"), #os.date("%H:%M:%S")); | 465 width = date_or_time_width; |
| 466 align = "right"; | |
| 467 mapper = date_or_time; | |
| 468 }; | |
| 469 { | |
| 470 title = "Expires"; | |
| 471 key = "expires"; | |
| 472 width = date_or_time_width; | |
| 463 align = "right"; | 473 align = "right"; |
| 464 mapper = date_or_time; | 474 mapper = date_or_time; |
| 465 }; | 475 }; |
| 466 { | 476 { |
| 467 title = "Authentication"; | 477 title = "Authentication"; |
