diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-22 19:58:39 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-22 19:58:39 +0000 |
commit | 8cfe28d0691856222685b93f4a58664416a0aa65 (patch) | |
tree | bdc57542af8a67aefbd4b587b6aa9d5483ca3e55 /app/acf-util/password-controller.lua | |
parent | a1ad49891bbeea6c4c5cf77a574d219c9a722eab (diff) | |
download | acf-core-8cfe28d0691856222685b93f4a58664416a0aa65.tar.bz2 acf-core-8cfe28d0691856222685b93f4a58664416a0aa65.tar.xz |
Split common code out of authenticator-plaintext into authenticator.lua in preparation for adding SQL authentication. Rewrote authentication functions to use cfe's. Made corresponding changes to roles and logon. Added dnsfiles field to userdata for tinydns access control.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1314 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'app/acf-util/password-controller.lua')
-rwxr-xr-x | app/acf-util/password-controller.lua | 132 |
1 files changed, 47 insertions, 85 deletions
diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua index 20f04ef..bea4480 100755 --- a/app/acf-util/password-controller.lua +++ b/app/acf-util/password-controller.lua @@ -8,97 +8,59 @@ function status(self) 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 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 - output.descr = "Saved user" - end - output = self:redirect_to_referrer(output) - else - output = self:redirect_to_referrer() or output - end - - -- Don't allow changing of roles for yourself - output.value.roles = nil - - output.type = "form" - output.label = "Edit My Settings" - output.option = "Save" - return output + -- just to make sure can't modify any other user from this action + self.clientdata.userid = self.sessiondata.userinfo.userid + return controllerfunctions.handle_form(self, function() + local value = self.model.read_user(self, self.sessiondata.userinfo.userid) + -- We don't allow a user to modify his own roles or dnsfiles + value.value.roles = nil + value.value.dnsfiles = nil + return value + end, function(value) + -- If password and password_confirm are blank, don't set them + local pw, pwc + if value.value.password.value == "" and value.value.password_confirm.value == "" then + pw = value.value.password + pwc = value.value.password_confirm + value.value.password = nil + value.value.password_confirm = nil + end + value = self.model.update_user(self, value) + if pw then + value.value.password = pw + value.value.password_confirm = pwc + end + return value + end, self.clientdata, "Save", "Edit My Settings", "Saved user") end function edituser(self) - local output = self.model.read_user(self, self.clientdata.userid) - 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 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 - redirect(self, "status") - end - output = self:redirect_to_referrer(output) - else - output = self:redirect_to_referrer() or output - end - - output.type = "form" - output.label = "Edit User Settings" - output.option = "Save" - return output + return controllerfunctions.handle_form(self, function() + return self.model.read_user(self, self.clientdata.userid) + end, function(value) + -- If password and password_confirm are blank, don't set them + local pw, pwc + if value.value.password.value == "" and value.value.password_confirm.value == "" then + pw = value.value.password + pwc = value.value.password_confirm + value.value.password = nil + value.value.password_confirm = nil + end + value = self.model.update_user(self, value) + if pw then + value.value.password = pw + value.value.password_confirm = pwc + end + return value + end, self.clientdata, "Save", "Edit User Settings", "Saved user") end function newuser(self) - local output = self.model.read_user(self) - if self.clientdata.Save then - controllerfunctions.handle_clientdata(output, clientdata) - - -- Update userinfo - output = self.model.create_user(self, output) - if not output.errtxt then - redirect(self, "status") - end - output = self:redirect_to_referrer(output) - else - output = self:redirect_to_referrer() or output - end - - output.type = "form" - output.label = "New User Settings" - output.option = "Save" - return output + return controllerfunctions.handle_form(self, function() + return self.model.read_user(self) + end, function(value) + return self.model.create_user(self, value) + end, self.clientdata, "Save", "New User Settings", "Saved user", "status") end function deleteuser(self) |