liquid_feedback_frontend

view app/main/_filter/21_auth.lua @ 729:f52f918b38b8

Cleanup of config and orphaned code
author bsw
date Thu Jun 28 17:07:00 2012 +0200 (2012-06-28)
parents 344e5fdce8c9
children 80a58850bf87
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 config.public_access 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 then
38 auth_needed = false
39 end
41 end
43 if config.public_access == "full" then
44 if module == "member_image" and view == "show"
45 or module == "vote" and view == "show_incoming"
46 or module == "interest" and view == "show_incoming"
47 or module == "supporter" and view == "show_incoming" then
48 auth_needed = false
49 end
50 end
52 if module == "sitemap" then
53 auth_needed = false
54 end
56 if config.public_access and not app.session.member_id and auth_needed and module == "index" and view == "index" then
57 if config.single_unit_id then
58 request.redirect{ module = "unit", view = "show", id = config.single_unit_id }
59 else
60 request.redirect{ module = "unit", view = "list" }
61 end
62 return
63 end
65 -- if not app.session.user_id then
66 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
67 -- app.session.user_id = 1
68 -- end
70 if auth_needed and app.session.member == nil then
71 trace.debug("Not authenticated yet.")
72 request.redirect{
73 module = 'index', view = 'login', params = {
74 redirect_module = module,
75 redirect_view = view,
76 redirect_id = param.get_id()
77 }
78 }
79 elseif auth_needed and app.session.member.locked then
80 trace.debug("Member locked.")
81 request.redirect{ module = 'index', view = 'login' }
82 else
83 if auth_needed then
84 trace.debug("Authentication accepted.")
85 else
86 trace.debug("No authentication needed.")
87 end
89 --db:query("SELECT check_everything()")
91 execute.inner()
92 trace.debug("End of authentication filter.")
93 end

Impressum / About Us