liquid_feedback_frontend

view app/main/oauth2/_action/accept_scope.lua @ 1540:b0b557858fd8

Fixed access to non-existing session object in auth filter
author bsw
date Tue Oct 20 17:58:07 2020 +0200 (2020-10-20)
parents 32cc544d5a5b
children
line source
1 local system_application_id = param.get("system_application_id", atom.integer)
2 local domain = param.get("domain")
3 local response_type = param.get("response_type")
5 if domain then
6 domain = string.lower(domain)
7 end
8 local scopes = {}
9 for i = 0, math.huge do
10 scopes[i] = param.get("scope" .. i)
11 if not scopes[i] then
12 break
13 end
14 end
16 local redirect_uri = param.get("redirect_uri")
17 local redirect_uri_explicit = param.get("redirect_uri_explicit", atom.boolean)
18 local state = param.get("state")
20 local selector
22 if system_application_id then
23 selector = MemberApplication:get_selector_by_member_id_and_system_application_id(app.session.member_id, system_application_id)
24 else
25 selector = MemberApplication:get_selector_by_member_id_and_domain(app.session.member_id, domain)
26 end
27 selector:for_update()
29 local member_application = selector:exec()
31 if not member_application then
32 member_application = MemberApplication:new()
33 member_application.member_id = app.session.member_id
34 member_application.system_application_id = system_application_id
35 member_application.domain = domain
36 end
38 local new_scopes = {}
40 for i = 0, #scopes do
41 if scopes[i] then
42 for scope in string.gmatch(scopes[i], "[^ ]+") do
43 new_scopes[scope] = true
44 end
45 end
46 end
48 if member_application.scopes then
49 for scope in string.gmatch(member_application.scopes, "[^ ]+") do
50 new_scopes[scope] = true
51 end
52 end
54 local new_scopes_list = {}
56 for k, v in pairs(new_scopes) do
57 new_scopes_list[#new_scopes_list+1] = k
58 end
60 local new_scopes_string = table.concat(new_scopes_list, " ")
62 member_application.scope = new_scopes_string
64 member_application:save()
66 execute.chunk{ module = "oauth2", chunk = "_authorization", params = {
67 member_id = app.session.member_id,
68 system_application_id = system_application_id,
69 domain = domain,
70 session_id = app.session.id,
71 redirect_uri = redirect_uri,
72 redirect_uri_explicit = redirect_uri_explicit,
73 scopes = scopes,
74 state = state,
75 response_type = response_type
76 } }

Impressum / About Us