Software /
code /
prosody-modules
Diff
mod_http_oauth2/mod_http_oauth2.lua @ 5427:d69c10327d6d
mod_http_oauth2: More functional functions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 07 May 2023 19:11:20 +0200 |
parent | 5426:f75d95f27da7 |
child | 5428:07e166b34c4c |
line wrap: on
line diff
--- a/mod_http_oauth2/mod_http_oauth2.lua Sun May 07 19:07:52 2023 +0200 +++ b/mod_http_oauth2/mod_http_oauth2.lua Sun May 07 19:11:20 2023 +0200 @@ -116,10 +116,14 @@ return usermanager.user_can_assume_role(username, module.host, requested_role); end +local function role_assumable_by(username) + return function(role) + return can_assume_role(username, role); + end +end + local function user_assumable_roles(username, requested_roles) - return array.filter(requested_roles, function(role) - return can_assume_role(username, role); - end); + return array.filter(requested_roles, role_assumable_by(username)); end local function select_role(username, requested_roles)