liquid_feedback_frontend

view app/main/_filter/21_auth.lua @ 1668:6d75df24e66e

Updated German translation
author bsw
date Sun Mar 07 09:52:36 2021 +0100 (2021-03-07)
parents cbce4491c93e
children 446d2798f424
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 == "policy" and view == "show"
65 or module == "policy" and view == "list"
66 or module == "issue" and view == "show"
67 or module == "issue" and view == "history"
68 or module == "initiative" and view == "show"
69 or module == "initiative" and view == "history"
70 or module == "suggestion" and view == "show"
71 or module == "draft" and view == "diff"
72 or module == "draft" and view == "show"
73 or module == "file" and view == "show.jpg"
74 or module == "index" and view == "search"
75 or module == "index" and view == "usage_terms"
76 or module == "help" and view == "introduction"
77 or module == "style"
78 then
79 auth_needed = false
80 end
82 end
84 if app.session:has_access("authors_pseudonymous") then
85 if module == "member_image" and view == "show" and param.get("image_type") == "avatar" then
86 auth_needed = false
87 end
88 end
90 if app.session:has_access("everything") then
91 if module == "member_image" and view == "show" then
92 auth_needed = false
93 end
94 end
96 if app.session:has_access("all_pseudonymous") then
97 if module == "vote" and view == "show_incoming"
98 or module == "member" and view == "list"
99 or module == "interest" and view == "show_incoming"
100 or module == "vote" and view == "list" then
101 auth_needed = false
102 end
103 end
105 if app.session:has_access("everything") then
106 if module == "member" and (view == "show" or view == "history") then
107 auth_needed = false
108 end
109 end
111 if module == "sitemap" then
112 auth_needed = false
113 end
115 if app.session:has_access("anonymous") and not app.session.member_id and auth_needed and module == "index" and view == "index" then
116 if config.single_unit_id then
117 request.redirect{ module = "unit", view = "show", id = config.single_unit_id }
118 else
119 request.redirect{ module = "unit", view = "list" }
120 end
121 return
122 end
124 -- if not app.session.user_id then
125 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
126 -- app.session.user_id = 1
127 -- end
129 if auth_needed and app.session.member == nil then
130 trace.debug("Not authenticated yet.")
131 local params = json.object()
132 for key, val in pairs(request.get_param_strings()) do
133 if type(val) == "string" then
134 params[key] = val
135 else
136 -- shouldn't happen
137 error("array type params not implemented")
138 end
139 end
140 request.redirect{
141 module = 'index', view = 'login', params = {
142 redirect_module = module,
143 redirect_view = view,
144 redirect_id = param.get_id(),
145 redirect_params = params
146 }
147 }
148 elseif auth_needed and app.session.member.locked then
149 trace.debug("Member locked.")
150 request.redirect{ module = 'index', view = 'login' }
151 else
152 if config.check_delegations_interval_hard and app.session.member_id and app.session.needs_delegation_check
153 and not (module == "admin" or (module == "index" and (
154 view == "check_delegations"
155 or action == "check_delegations"
156 or action == "logout"
157 or view == "about"
158 or view == "usage_terms"
159 or action == "set_lang")
160 ))
161 and not (module == "member_image" and view == "show") then
162 request.redirect{ module = 'index', view = 'check_delegations' }
163 return
164 end
165 if auth_needed then
166 trace.debug("Authentication accepted.")
167 else
168 trace.debug("No authentication needed.")
169 end
171 --db:query("SELECT check_everything()")
173 execute.inner()
174 trace.debug("End of authentication filter.")
175 end

Impressum / About Us