liquid_feedback_frontend

changeset 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 202876945a6c
children 020fd82c6cb4
files app/main/oauth2/token.lua app/main/oauth2/validate.lua
line diff
     1.1 --- a/app/main/oauth2/token.lua	Tue Jan 26 18:19:13 2021 +0100
     1.2 +++ b/app/main/oauth2/token.lua	Tue Jan 26 18:52:28 2021 +0100
     1.3 @@ -273,14 +273,6 @@
     1.4          r.real_member.identification = token.session.real_member.identification
     1.5        end
     1.6      end
     1.7 -    if unit.attr.role and param.get("include_roles") then
     1.8 -      r.roles = json.object()
     1.9 -      if not unit.attr.only_visible_for_role 
    1.10 -        or member:has_role(unit.attr.only_visible_for_role)
    1.11 -      then
    1.12 -        r.roles[unit.attr.role] = true
    1.13 -      end
    1.14 -    end
    1.15    end
    1.16  end
    1.17  
     2.1 --- a/app/main/oauth2/validate.lua	Tue Jan 26 18:19:13 2021 +0100
     2.2 +++ b/app/main/oauth2/validate.lua	Tue Jan 26 18:52:28 2021 +0100
     2.3 @@ -57,8 +57,8 @@
     2.4    r.real_member_id = token.session.real_member_id
     2.5  end
     2.6  
     2.7 -if param.get("include_member", atom.boolean) then
     2.8 -  if scopes.identification or scopes.authentication then
     2.9 +if scopes.identification or scopes.authentication then
    2.10 +  if param.get("include_member", atom.boolean) then
    2.11      local member = token.member
    2.12      r.member = json.object{
    2.13        id = member.id,
    2.14 @@ -79,6 +79,18 @@
    2.15      if param.get("include_member_notify_email", atom.boolean) then
    2.16        r.member.notify_email = member.notify_email
    2.17      end
    2.18 +    if param.get("include_roles") then
    2.19 +      for i, unit in ipairs(member.units) do
    2.20 +        if unit.attr.role then
    2.21 +          r.roles = json.object()
    2.22 +          if not unit.attr.only_visible_for_role 
    2.23 +            or member:has_role(unit.attr.only_visible_for_role)
    2.24 +          then
    2.25 +            r.roles[unit.attr.role] = true
    2.26 +          end
    2.27 +        end
    2.28 +      end
    2.29 +    end
    2.30    end
    2.31  end
    2.32  

Impressum / About Us