liquid_feedback_frontend

view app/main/_filter/21_auth.lua @ 1800:b87997219042

Updated spanish translation
author bsw
date Thu Oct 21 15:22:29 2021 +0200 (2021-10-21)
parents c28ff4a85ded
children 2e5b303ea68e
line source
1 local module = request.get_module()
2 local view = request.get_view()
3 local action = request.get_action()
5 local auth_needed = true
7 if module == 'index' and (
8 view == "login"
9 or action == "login"
10 or view == "register"
11 or action == "register"
12 or action == "cancel_register"
13 or view == "about"
14 or view == "reset_password"
15 or action == "reset_password"
16 or view == "send_login"
17 or action == "send_login"
18 or view == "confirm_notify_email"
19 or action == "confirm_notify_email"
20 or view == "menu"
21 or action == "set_lang"
22 or view == "403"
23 or view == "404"
24 or view == "405"
25 ) then
26 auth_needed = false
27 end
29 if module == "registration" then
30 auth_needed = false
31 end
33 if module == "style" then
34 auth_needed = false
35 end
37 if module == "help" then
38 auth_needed = false
39 end
41 if module == "oauth2" and (
42 view == "validate"
43 or view == "token"
44 or view == "session"
45 or view == "register"
46 ) then
47 auth_needed = false
48 end
50 if module == "oauth2_client" then
51 auth_needed = false
52 end
54 if module == "api" then
55 auth_needed = false
56 end
58 if app.session:has_access("anonymous") then
60 if
61 module == "index" and view == "index"
62 or module == "area" and view == "show"
63 or module == "unit" and view == "show"
64 or module == "issue" and view == "show"
65 or module == "issue" and view == "history"
66 or module == "initiative" and view == "show"
67 or module == "initiative" and view == "history"
68 or module == "suggestion" and view == "show"
69 or module == "draft" and view == "diff"
70 or module == "draft" and view == "show"
71 or module == "file" and view == "show.jpg"
72 or module == "index" and view == "search"
73 or module == "index" and view == "usage_terms"
74 or module == "help" and view == "introduction"
75 or module == "style"
76 then
77 auth_needed = false
78 end
80 end
82 if app.session:has_access("authors_pseudonymous") then
83 if module == "member_image" and view == "show" and param.get("image_type") == "avatar" then
84 auth_needed = false
85 end
86 end
88 if app.session:has_access("everything") then
89 if module == "member_image" and view == "show" then
90 auth_needed = false
91 end
92 end
94 if app.session:has_access("all_pseudonymous") then
95 if module == "vote" and view == "show_incoming"
96 or module == "member" and view == "list"
97 or module == "interest" and view == "show_incoming"
98 or module == "vote" and view == "list" then
99 auth_needed = false
100 end
101 end
103 if app.session:has_access("everything") then
104 if module == "member" and (view == "show" or view == "history") then
105 auth_needed = false
106 end
107 end
109 if module == "sitemap" then
110 auth_needed = false
111 end
113 if app.session:has_access("anonymous") and not app.session.member_id and auth_needed and module == "index" and view == "index" then
114 if app.single_unit_id then
115 request.redirect{ module = "unit", view = "show", id = app.single_unit_id }
116 else
117 request.redirect{ module = "unit", view = "list" }
118 end
119 return
120 end
122 -- if not app.session.user_id then
123 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
124 -- app.session.user_id = 1
125 -- end
127 if auth_needed and app.session.member == nil then
128 trace.debug("Not authenticated yet.")
129 local params = json.object()
130 for key, val in pairs(request.get_param_strings()) do
131 if type(val) == "string" then
132 params[key] = val
133 else
134 -- shouldn't happen
135 error("array type params not implemented")
136 end
137 end
138 if config.login and config.login.method == "oauth2" then
139 request.redirect{
140 module = "oauth2_client",
141 view = "redirect",
142 params = { provider = config.login.provider }
143 }
144 else
145 request.redirect{
146 module = 'index', view = 'login', params = {
147 redirect_module = module,
148 redirect_view = view,
149 redirect_id = param.get_id(),
150 redirect_params = params
151 }
152 }
153 end
154 elseif auth_needed and app.session.member.locked then
155 trace.debug("Member locked.")
156 request.redirect{ module = 'index', view = 'login' }
157 else
158 if config.check_delegations_interval_hard and app.session.member_id and app.session.needs_delegation_check
159 and not (module == "admin" or (module == "index" and (
160 view == "check_delegations"
161 or action == "check_delegations"
162 or action == "logout"
163 or view == "about"
164 or view == "usage_terms"
165 or action == "set_lang")
166 ))
167 and not (module == "member_image" and view == "show") then
168 request.redirect{ module = 'index', view = 'check_delegations' }
169 return
170 end
171 if auth_needed then
172 trace.debug("Authentication accepted.")
173 else
174 trace.debug("No authentication needed.")
175 end
177 --db:query("SELECT check_everything()")
179 execute.inner()
180 trace.debug("End of authentication filter.")
181 end

Impressum / About Us