diff options
Diffstat (limited to 'app')
-rwxr-xr-x | app/acf-util/password-controller.lua | 39 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 16 |
2 files changed, 24 insertions, 31 deletions
diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua index b248808..20f04ef 100755 --- a/app/acf-util/password-controller.lua +++ b/app/acf-util/password-controller.lua @@ -1,4 +1,5 @@ module(..., package.seeall) +require("controllerfunctions") default_action = "editme" @@ -8,20 +9,26 @@ end function editme(self) local output = self.model.read_user(self, self.sessiondata.userinfo.userid) + if clientdata.Save then -- just to make sure can't modify any other user from this action self.clientdata.userid = self.sessiondata.userinfo.userid -- As a special case for update_user, settings that don't change are nil self.clientdata.roles = nil + output.value.roles.value = nil -- if password is blank, don't update it or require it - if self.clientdata.password == "" then self.clientdata.password = nil end - if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end - - for name,value in pairs(output.value) do - value.value = self.clientdata[name] + if not self.clientdata.password or self.clientdata.password == "" then + self.clientdata.password = nil + output.value.password.value = nil + end + if not self.clientdata.password_confirm or self.clientdata.password_confirm == "" then + self.clientdata.password_confirm = nil + output.value.password_confirm.value = nil end + controllerfunctions.handle_clientdata(output, clientdata) + -- Update userinfo output = self.model.update_user(self, output) if not output.errtxt then @@ -34,7 +41,7 @@ function editme(self) -- Don't allow changing of roles for yourself output.value.roles = nil - + output.type = "form" output.label = "Edit My Settings" output.option = "Save" @@ -46,13 +53,17 @@ function edituser(self) if self.clientdata.Save then -- As a special case for update_user, settings that don't change are nil -- if password is blank, don't update it or require it - if self.clientdata.password == "" then self.clientdata.password = nil end - if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end - - for name,value in pairs(output.value) do - value.value = self.clientdata[name] + if not self.clientdata.password or self.clientdata.password == "" then + self.clientdata.password = nil + output.value.password.value = nil + end + if not self.clientdata.password_confirm or self.clientdata.password_confirm == "" then + self.clientdata.password_confirm = nil + output.value.password_confirm.value = nil end + controllerfunctions.handle_clientdata(output, clientdata) + -- Update userinfo output = self.model.update_user(self, output) if not output.errtxt then @@ -72,11 +83,7 @@ end function newuser(self) local output = self.model.read_user(self) if self.clientdata.Save then - for name,value in pairs(output.value) do - if self.clientdata[name] then - value.value = self.clientdata[name] - end - end + controllerfunctions.handle_clientdata(output, clientdata) -- Update userinfo output = self.model.create_user(self, output) diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index ce58893..cd8a49f 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -221,20 +221,6 @@ mvc.on_load = function (self, parent) self.clientdata = FORM self.conf.clientip = ENV.REMOTE_ADDR - -- FIXME this is because multi selects don't work in haserl - for name,oldtable in pairs(self.clientdata) do - if type(oldtable) == "table" then - -- Assume it's a sparse array, and remove blanks - local newtable={} - for x=1,table.maxn(oldtable) do - if oldtable[x] then - newtable[#newtable + 1] = oldtable[x] - end - end - self.clientdata[name] = newtable - end - end - parent_exception_handler = parent.exception_handler -- this sets the package path for us and our children @@ -488,7 +474,7 @@ redirect_to_referrer = function(self, result) -- might not have view. So redirect to default action for this controller. self:redirect() else - local prefix, controller, action = self.parse_path_info(ENV.HTTP_REFERER) + local prefix, controller, action = self.parse_path_info(ENV.HTTP_REFERER:gsub("%?.*", "")) if controller ~= self.conf.controller or action ~= self.conf.action then self.sessiondata[self.conf.action.."result"] = result error({type="redir_to_referrer"}) |