Software /
code /
prosody
Diff
core/usermanager.lua @ 12663:cf88f6b03942
mod_authz_internal: Expose convenience method to test if user can assume role
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 18 Aug 2022 10:37:59 +0100 |
parent | 12662:07424992d7fc |
child | 12664:05d5f25a3c61 |
line wrap: on
line diff
--- a/core/usermanager.lua Wed Aug 17 16:38:53 2022 +0100 +++ b/core/usermanager.lua Thu Aug 18 10:37:59 2022 +0100 @@ -164,6 +164,13 @@ return role, err; end +local function user_can_assume_role(user, host, role_name) + if host and not hosts[host] then return false; end + if type(user) ~= "string" then return false; end + + return hosts[host].authz.user_can_assume_role(user, role_name); +end + local function add_user_secondary_role(user, host, role_name) if host and not hosts[host] then return false; end if type(user) ~= "string" then return false; end @@ -260,6 +267,7 @@ get_provider = get_provider; get_user_role = get_user_role; set_user_role = set_user_role; + user_can_assume_role = user_can_assume_role; add_user_secondary_role = add_user_secondary_role; remove_user_secondary_role = remove_user_secondary_role; get_user_secondary_roles = get_user_secondary_roles;