webmcp

view demo-app/app/main/_filter/21_auth.lua @ 324:1c3ba14bd679

Root __init.lua function must not set global variables without _G now; Documentation for "_" function added
author jbe
date Mon Mar 23 22:41:40 2015 +0100 (2015-03-23)
parents 9fdfb27f8e67
children
line source
1 local auth_needed = not (
2 request.get_module() == 'index'
3 and (
4 request.get_view() == 'login'
5 or request.get_action() == 'login'
6 )
7 )
9 -- if not app.session.user_id then
10 -- trace.debug("DEBUG: AUTHENTICATION BYPASS ENABLED")
11 -- app.session.user_id = 1
12 -- end
14 if app.session.user == nil and auth_needed then
15 trace.debug("Not authenticated yet.")
16 request.redirect{ module = 'index', view = 'login' }
17 else
18 if auth_needed then
19 trace.debug("Authentication accepted.")
20 else
21 trace.debug("No authentication needed.")
22 end
23 execute.inner()
24 trace.debug("End of authentication filter.")
25 end

Impressum / About Us