diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-05-30 22:57:06 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-05-30 22:57:06 +0000 |
commit | 3d4463e2b16596960ff7ba44a93b87afeeea2831 (patch) | |
tree | 0590b43a603b42d539879a282a37db442f207af8 | |
parent | 2d34b61db1eb8f4f59ee22907c98a911eddcee9f (diff) | |
download | acf-core-3d4463e2b16596960ff7ba44a93b87afeeea2831.tar.bz2 acf-core-3d4463e2b16596960ff7ba44a93b87afeeea2831.tar.xz |
Add home config option to acf.conf for default home page
The default_prefix and default_controller logic was broken, and is now removed
-rw-r--r-- | acf.conf | 3 | ||||
-rw-r--r-- | app/acf-util/logon-controller.lua | 4 | ||||
-rw-r--r-- | app/acf_cli-controller.lua | 2 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 49 | ||||
-rwxr-xr-x | lua/mvc.lua | 7 |
5 files changed, 34 insertions, 31 deletions
@@ -37,3 +37,6 @@ skin=/skins/wik # For specific controller-based auditing, create acf-hooks.lua # in this directory (see svn sources for an example) + +# Home page for web access (overridable for users after logon) +home=/acf-util/logon/logon diff --git a/app/acf-util/logon-controller.lua b/app/acf-util/logon-controller.lua index 6ac293e..4fa3d20 100644 --- a/app/acf-util/logon-controller.lua +++ b/app/acf-util/logon-controller.lua @@ -29,7 +29,7 @@ logon = function(self) if clientdata.submit then local logonredirect = self.sessiondata.logonredirect local logon = self.model:logon(clientdata.userid, clientdata.password, conf.clientip, conf.sessiondir, sessiondata) - -- If successful logon, redirect to welcome-page, otherwise try again + -- If successful logon, redirect to home or welcome page, otherwise try again if logon.value then cmdresult.descr = "Logon Successful" else @@ -41,6 +41,8 @@ logon = function(self) if redir.value == "" then if self.sessiondata.userinfo and self.sessiondata.userinfo.home and self.sessiondata.userinfo.home ~= "" then redir.value = self.sessiondata.userinfo.home + elseif self.conf.home and self.conf.home ~= "" then + redir.value = self.conf.home else redir.value = "/acf-util/welcome/read" end diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua index f2291e0..130d60a 100644 --- a/app/acf_cli-controller.lua +++ b/app/acf_cli-controller.lua @@ -9,8 +9,6 @@ mvc.on_load = function (self, parent) -- Make sure we have some kind of sane defaults for libdir self.conf.libdir = self.conf.libdir or ( string.match(self.conf.appdir, "[^,]+/") .. "/lib/" ) self.conf.script = "" - self.conf.default_prefix = "/acf-util/" - self.conf.default_controller = "welcome" self.conf.viewtype = "serialized" parent_exception_handler = parent.exception_handler diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index 2ff2179..4aa5b44 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -220,8 +220,6 @@ mvc.on_load = function (self, parent) self.conf.wwwdir = self.conf.wwwdir or ( string.match(self.conf.appdir, "[^,]+/") .. "/www/" ) self.conf.sessiondir = self.conf.sessiondir or "/tmp/" self.conf.script = ENV.SCRIPT_NAME - self.conf.default_prefix = "/acf-util/" - self.conf.default_controller = self.conf.default_controller or "welcome" self.clientdata = FORM self.conf.clientip = ENV.REMOTE_ADDR @@ -325,7 +323,11 @@ exception_handler = function (self, message ) self.sessiondata.logonredirect.clientdata = self.clientdata self.sessiondata.logonredirect.clientdata.sessionid = nil self.sessiondata.logonredirect.referrer = ENV.HTTP_REFERER - io.write ("Location: " .. ENV["SCRIPT_NAME"] .. "/acf-util/logon/logon?redir="..message.prefix..message.controller.."/"..message.action.."\n") + if message.controller ~= "" then + io.write ("Location: " .. ENV["SCRIPT_NAME"] .. "/acf-util/logon/logon?redir="..message.prefix..message.controller.."/"..message.action.."\n") + else + io.write ("Location: " .. ENV["SCRIPT_NAME"] .. "/acf-util/logon/logon\n") + end else io.write ("Location: " .. ENV.HTTP_REFERER .. "\n") end @@ -376,7 +378,7 @@ dispatch = function (self, userprefix, userctlr, useraction) parse_path_info(ENV["PATH_INFO"]) self.conf.wwwprefix = string.gsub(ENV["SCRIPT_NAME"] or "", "/?cgi%-bin/acf.*", "") else - self.conf.prefix = userprefix + self.conf.prefix = userprefix or "/" self.conf.controller = userctlr or "" self.conf.action = useraction or "" end @@ -390,20 +392,37 @@ dispatch = function (self, userprefix, userctlr, useraction) self.sessiondata.logonredirect = nil end - -- Find the proper controller/action combo + -- Before we start checking for views, set the viewtype (also before any redirect or dispatch error) + if self.clientdata.viewtype then + self.conf.viewtype = self.clientdata.viewtype + else + self.conf.viewtype = "html" + end + + -- Find the proper prefix/controller/action combo local origconf = {} for name,value in pairs(self.conf) do origconf[name]=value end if "" == self.conf.controller and self.sessiondata.userinfo and self.sessiondata.userinfo.home and self.sessiondata.userinfo.home ~= "" then self.conf.prefix, self.conf.controller, self.conf.action = parse_path_info(self.sessiondata.userinfo.home) end + if "" == self.conf.controller and self.conf.home and self.conf.home ~= "" then + self.conf.prefix, self.conf.controller, self.conf.action = + parse_path_info(self.conf.home) + end if "" == self.conf.controller then - self.conf.prefix = self.conf.default_prefix or "/" - self.conf.controller = self.conf.default_controller or "" - self.conf.action = "" + self.conf.prefix = "/acf-util/" + self.conf.controller = "welcome" + self.conf.action = "read" + end + + -- If we have different prefix / controller / action, redirect + if self.conf.prefix ~= origconf.prefix or self.conf.controller ~= origconf.controller or self.conf.action ~= origconf.action then + redirect(self, self.conf.action) -- controller and prefix already in self.conf end + if "" ~= self.conf.controller then - -- We now know the controller / action combo, check if we're allowed to do it + -- We now know the prefix / controller / action combo, check if we're allowed to do it local perm = check_permission(self, self.conf.prefix, self.conf.controller) local worker_loaded = false @@ -430,18 +449,6 @@ dispatch = function (self, userprefix, userctlr, useraction) end end - -- If we have different controller / action, redirect - if self.conf.controller ~= origconf.controller or self.conf.action ~= origconf.action then - redirect(self, self.conf.action) -- controller and prefix already in self.conf - end - - -- Before we start checking for views, set the viewtype - if self.clientdata.viewtype then - self.conf.viewtype = self.clientdata.viewtype - else - self.conf.viewtype = "html" - end - -- If the controller or action are missing, display an error view if nil == controller then -- If we have a view w/o an action, just display the view (passing in the clientdata) diff --git a/lua/mvc.lua b/lua/mvc.lua index aa0cc28..863b45f 100755 --- a/lua/mvc.lua +++ b/lua/mvc.lua @@ -136,13 +136,6 @@ dispatch = function (self, userprefix, userctlr, useraction, clientdata) self.conf.action = useraction or "" if clientdata then self.clientdata = clientdata end - -- If they didn't provide a controller, and a default was specified - -- use it - if self.conf.controller == "" and self.conf.default_controller then - self.conf.controller = self.conf.default_controller - self.conf.prefix = self.conf.default_prefix or "/" - end - local worker_loaded controller, worker_loaded = self:new(self.conf.prefix .. self.conf.controller) |