diff options
Diffstat (limited to 'app/acf-util/password-controller.lua')
-rwxr-xr-x | app/acf-util/password-controller.lua | 39 |
1 files changed, 23 insertions, 16 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) |