Mercurial > prosody-modules
comparison mod_http_oauth2/mod_http_oauth2.lua @ 6295:c96bd4156664
mod_http_oauth2: Fix passing roles and scopes the same way to template
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 15 Jul 2025 21:55:25 +0200 |
| parents | 6e80b2cb5fe6 |
| children | 3f0970babd67 |
comparison
equal
deleted
inserted
replaced
| 6294:24559118dd6c | 6295:c96bd4156664 |
|---|---|
| 36 if haystack[i] == needle then | 36 if haystack[i] == needle then |
| 37 return true | 37 return true |
| 38 end | 38 end |
| 39 end | 39 end |
| 40 return false | 40 return false |
| 41 end | |
| 42 | |
| 43 local function array_filter(haystack) | |
| 44 return function (needle) | |
| 45 return array_contains(haystack, needle); | |
| 46 end | |
| 41 end | 47 end |
| 42 | 48 |
| 43 local function strict_url_parse(urlstr) | 49 local function strict_url_parse(urlstr) |
| 44 local url_parts = url.parse(urlstr); | 50 local url_parts = url.parse(urlstr); |
| 45 if not url_parts then return url_parts; end | 51 if not url_parts then return url_parts; end |
| 1051 return false; | 1057 return false; |
| 1052 end | 1058 end |
| 1053 end); | 1059 end); |
| 1054 for _, role in ipairs(roles) do | 1060 for _, role in ipairs(roles) do |
| 1055 if role == "xmpp" then | 1061 if role == "xmpp" then |
| 1056 scope_choices:push({ scope = role; title = "XMPP"; | 1062 scope_choices:push({ claim = role; title = "XMPP"; |
| 1057 description = "Unlimited access to your account, including sending and receiving messages."; }); | 1063 description = "Unlimited access to your account, including sending and receiving messages."; }); |
| 1058 else | 1064 else |
| 1059 scope_choices:push({ scope = role; title = role, description = "Prosody Role" }); | 1065 scope_choices:push({ claim = role; title = role, description = "Prosody Role" }); |
| 1060 end | 1066 end |
| 1061 end | 1067 end |
| 1062 return render_page(templates.consent, { state = auth_state; client = client; scopes = scope_choices }, true); | 1068 return render_page(templates.consent, { state = auth_state; client = client; scopes = scope_choices }, true); |
| 1063 end | 1069 end |
| 1064 elseif not auth_state.consent then | 1070 elseif not auth_state.consent then |
