liquid_feedback_frontend

view app/main/_filter/21_auth.lua @ 813:ea2449916c12

Cleaned up public access levels
author bsw
date Fri Jul 06 13:58:20 2012 +0200 (2012-07-06)
parents 8a3070a2297d
children ea3d3757ddc3
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 == "index"
9 or view == "login"
10 or action == "login"
11 or view == "register"
12 or action == "register"
13 or view == "about"
14 or view == "reset_password"
15 or action == "reset_password"
16 or view == "confirm_notify_email"
17 or action == "confirm_notify_email"
18 or view == "menu"
19 or action == "set_lang"
20 )
21 )
23 if app.session:has_access("anonymous") then
25 if
26 module == "area" and view == "show"
27 or module == "unit" and view == "show"
28 or module == "policy" and view == "show"
29 or module == "policy" and view == "list"
30 or module == "issue" and view == "show"
31 or module == "initiative" and view == "show"
32 or module == "suggestion" and view == "show"
33 or module == "draft" and view == "diff"
34 or module == "draft" and view == "show"
35 or module == "draft" and view == "list"
36 or module == "index" and view == "search"
37 or module == "index" and view == "usage_terms"
38 then
39 auth_needed = false
40 end
42 end
44 if app.session:has_access("all_pseudonymous") then
45 if module == "member_image" and view == "show"
46 or module == "vote" and view == "show_incoming"
47 or module == "interest" and view == "show_incoming"
48 or module == "supporter" and view == "show_incoming" then
49 auth_needed = false
50 end
51 end
53 if app.session:has_access("everything") then
54 if module == "member" and (view == "show" or view == "history") then
55 auth_needed = false
56 end
57 end
59 if module == "sitemap" then
60 auth_needed = false
61 end
63 if app.session:has_access("anonymous") and not app.session.member_id and auth_needed and module == "index" and view == "index" then
64 if config.single_unit_id then
65 request.redirect{ module = "unit", view = "show", id = config.single_unit_id }
66 else
67 request.redirect{ module = "unit", view = "list" }
68 end
69 return
70 end
72 -- if not app.session.user_id then
73 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
74 -- app.session.user_id = 1
75 -- end
77 if auth_needed and app.session.member == nil then
78 trace.debug("Not authenticated yet.")
79 request.redirect{
80 module = 'index', view = 'login', params = {
81 redirect_module = module,
82 redirect_view = view,
83 redirect_id = param.get_id()
84 }
85 }
86 elseif auth_needed and app.session.member.locked then
87 trace.debug("Member locked.")
88 request.redirect{ module = 'index', view = 'login' }
89 else
90 if auth_needed then
91 trace.debug("Authentication accepted.")
92 else
93 trace.debug("No authentication needed.")
94 end
96 --db:query("SELECT check_everything()")
98 execute.inner()
99 trace.debug("End of authentication filter.")
100 end

Impressum / About Us