liquid_feedback_frontend
changeset 1582:b4a377306a34
Allow fetching roles during token exchange
author | bsw |
---|---|
date | Tue Jan 26 17:42:36 2021 +0100 (2021-01-26) |
parents | 2373160319dc |
children | 202876945a6c |
files | app/main/oauth2/token.lua |
line diff
1.1 --- a/app/main/oauth2/token.lua Tue Jan 26 14:45:20 2021 +0100 1.2 +++ b/app/main/oauth2/token.lua Tue Jan 26 17:42:36 2021 +0100 1.3 @@ -254,8 +254,8 @@ 1.4 r.real_member_id = token.real_member_id 1.5 end 1.6 1.7 -if param.get("include_member", atom.boolean) then 1.8 - if allowed_scopes.identification or allowed_scopes.authentication then 1.9 +if allowed_scopes.identification or allowed_scopes.authentication then 1.10 + if param.get("include_member", atom.boolean) then 1.11 local member = token.member 1.12 r.member = json.object{ 1.13 id = member.id, 1.14 @@ -273,6 +273,14 @@ 1.15 r.real_member.identification = token.session.real_member.identification 1.16 end 1.17 end 1.18 + if unit.attr.role and param.get("include_roles") then 1.19 + r.roles = json.object() 1.20 + if not unit.attr.only_visible_for_role 1.21 + or member:has_role(unit.attr.only_visible_for_role) 1.22 + then 1.23 + r.roles[unit.attr.role] = true 1.24 + end 1.25 + end 1.26 end 1.27 end 1.28