liquid_feedback_frontend

diff app/main/oauth2/validate.lua @ 1584:2874a199c727

Removed include_role from token endpoint and added it to validate endpoint
author bsw
date Tue Jan 26 18:52:28 2021 +0100 (2021-01-26)
parents 6077545667ec
children 020fd82c6cb4
line diff
     1.1 --- a/app/main/oauth2/validate.lua	Tue Jan 26 18:19:13 2021 +0100
     1.2 +++ b/app/main/oauth2/validate.lua	Tue Jan 26 18:52:28 2021 +0100
     1.3 @@ -57,8 +57,8 @@
     1.4    r.real_member_id = token.session.real_member_id
     1.5  end
     1.6  
     1.7 -if param.get("include_member", atom.boolean) then
     1.8 -  if scopes.identification or scopes.authentication then
     1.9 +if scopes.identification or 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 @@ -79,6 +79,18 @@
    1.15      if param.get("include_member_notify_email", atom.boolean) then
    1.16        r.member.notify_email = member.notify_email
    1.17      end
    1.18 +    if param.get("include_roles") then
    1.19 +      for i, unit in ipairs(member.units) do
    1.20 +        if unit.attr.role then
    1.21 +          r.roles = json.object()
    1.22 +          if not unit.attr.only_visible_for_role 
    1.23 +            or member:has_role(unit.attr.only_visible_for_role)
    1.24 +          then
    1.25 +            r.roles[unit.attr.role] = true
    1.26 +          end
    1.27 +        end
    1.28 +      end
    1.29 +    end
    1.30    end
    1.31  end
    1.32  

Impressum / About Us