liquid_feedback_frontend

view app/main/_filter/21_auth.lua @ 1120:2d038d3ae153

Show introduction for non-members
author bsw
date Wed Dec 24 11:36:21 2014 +0100 (2014-12-24)
parents b9364e1b7994
children 32cc544d5a5b
line source
1 local module = request.get_module()
2 local view = request.get_view()
3 local action = request.get_action()
5 local auth_needed = not (
6 module == 'index'
7 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 == "404"
23 )
24 )
26 if app.session:has_access("anonymous") then
28 if
29 module == "index" and view == "index"
30 or module == "area" and view == "show"
31 or module == "unit" and view == "show"
32 or module == "policy" and view == "show"
33 or module == "policy" and view == "list"
34 or module == "issue" and view == "show"
35 or module == "issue" and view == "history"
36 or module == "initiative" and view == "show"
37 or module == "initiative" and view == "history"
38 or module == "suggestion" and view == "show"
39 or module == "draft" and view == "diff"
40 or module == "draft" and view == "show"
41 or module == "index" and view == "search"
42 or module == "index" and view == "usage_terms"
43 or module == "help" and view == "introduction"
44 then
45 auth_needed = false
46 end
48 end
50 if app.session:has_access("authors_pseudonymous") then
51 if module == "member_image" and view == "show" and param.get("image_type") == "avatar" then
52 auth_needed = false
53 end
54 end
56 if app.session:has_access("everything") then
57 if module == "member_image" and view == "show" then
58 auth_needed = false
59 end
60 end
62 if app.session:has_access("all_pseudonymous") then
63 if module == "vote" and view == "show_incoming"
64 or module == "member" and view == "list"
65 or module == "interest" and view == "show_incoming"
66 or module == "vote" and view == "list" then
67 auth_needed = false
68 end
69 end
71 if app.session:has_access("everything") then
72 if module == "member" and (view == "show" or view == "history") then
73 auth_needed = false
74 end
75 end
77 if module == "sitemap" then
78 auth_needed = false
79 end
81 if app.session:has_access("anonymous") and not app.session.member_id and auth_needed and module == "index" and view == "index" then
82 if config.single_unit_id then
83 request.redirect{ module = "unit", view = "show", id = config.single_unit_id }
84 else
85 request.redirect{ module = "unit", view = "list" }
86 end
87 return
88 end
90 -- if not app.session.user_id then
91 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
92 -- app.session.user_id = 1
93 -- end
95 if auth_needed and app.session.member == nil then
96 trace.debug("Not authenticated yet.")
97 request.redirect{
98 module = 'index', view = 'login', params = {
99 redirect_module = module,
100 redirect_view = view,
101 redirect_id = param.get_id()
102 }
103 }
104 elseif auth_needed and app.session.member.locked then
105 trace.debug("Member locked.")
106 request.redirect{ module = 'index', view = 'login' }
107 else
108 if config.check_delegations_interval_hard and app.session.member_id and app.session.needs_delegation_check
109 and not (module == "admin" or (module == "index" and (
110 view == "check_delegations"
111 or action == "check_delegations"
112 or action == "logout"
113 or view == "about"
114 or view == "usage_terms"
115 or action == "set_lang")
116 ))
117 and not (module == "member_image" and view == "show") then
118 request.redirect{ module = 'index', view = 'check_delegations' }
119 return
120 end
121 if auth_needed then
122 trace.debug("Authentication accepted.")
123 else
124 trace.debug("No authentication needed.")
125 end
127 --db:query("SELECT check_everything()")
129 execute.inner()
130 trace.debug("End of authentication filter.")
131 end

Impressum / About Us