Mercurial > prosody-modules
comparison mod_http_admin_api/mod_http_admin_api.lua @ 5775:4c3216d9b118
mod_http_admin_api: Include user account status and activity in get_user_info
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 06 Dec 2023 12:14:12 +0000 |
parents | 4c84cfb586c1 |
children | 6ab9e1763f35 |
comparison
equal
deleted
inserted
replaced
5774:7b722955c59b | 5775:4c3216d9b118 |
---|---|
12 local announce = module:depends("announce"); | 12 local announce = module:depends("announce"); |
13 local invites = module:depends("invites"); | 13 local invites = module:depends("invites"); |
14 local tokens = module:depends("tokenauth"); | 14 local tokens = module:depends("tokenauth"); |
15 local mod_pep = module:depends("pep"); | 15 local mod_pep = module:depends("pep"); |
16 local mod_groups = module:depends("groups_internal"); | 16 local mod_groups = module:depends("groups_internal"); |
17 local mod_lastlog2 = module:depends("lastlog2"); | |
17 | 18 |
18 local push_errors = module:shared("cloud_notify/push_errors"); | 19 local push_errors = module:shared("cloud_notify/push_errors"); |
19 | 20 |
20 local site_name = module:get_option_string("site_name", module.host); | 21 local site_name = module:get_option_string("site_name", module.host); |
21 | 22 |
25 | 26 |
26 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); | 27 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); |
27 | 28 |
28 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | 29 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; |
29 local xmlns_nick = "http://jabber.org/protocol/nick"; | 30 local xmlns_nick = "http://jabber.org/protocol/nick"; |
31 | |
32 assert(mod_lastlog2.get_last_active, "Newer version of mod_lastlog2 is required to use this module"); | |
30 | 33 |
31 local function check_credentials(request) | 34 local function check_credentials(request) |
32 local auth_type, auth_data = string.match(request.headers.authorization or "", "^(%S+)%s(.+)$"); | 35 local auth_type, auth_data = string.match(request.headers.authorization or "", "^(%S+)%s(.+)$"); |
33 if not (auth_type and auth_data) then | 36 if not (auth_type and auth_data) then |
34 return false; | 37 return false; |
193 for role_name in pairs(roles_map) do | 196 for role_name in pairs(roles_map) do |
194 legacy_roles:push(role_name); | 197 legacy_roles:push(role_name); |
195 end | 198 end |
196 end | 199 end |
197 | 200 |
201 local enabled = true; -- Assume all enabled if on a version without is_enabled | |
202 if usermanager.user_is_enabled then | |
203 enabled = usermanager.user_is_enabled(username, module.host); | |
204 end | |
205 | |
198 return { | 206 return { |
199 username = username; | 207 username = username; |
200 display_name = display_name; | 208 display_name = display_name; |
201 role = primary_role and primary_role.name or nil; | 209 role = primary_role and primary_role.name or nil; |
202 secondary_roles = secondary_roles; | 210 secondary_roles = secondary_roles; |
203 roles = legacy_roles; -- COMPAT w/0.12 | 211 roles = legacy_roles; -- COMPAT w/0.12 |
212 enabled = enabled; | |
213 last_active = mod_lastlog2.get_last_active(username); | |
204 }; | 214 }; |
205 end | 215 end |
206 | 216 |
207 local function get_session_debug_info(session) | 217 local function get_session_debug_info(session) |
208 local info = { | 218 local info = { |