From 27229e34b183a43da4c8868c457bf3cefd177403 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Mon, 3 Mar 2008 16:43:54 +0000 Subject: Redirecting the user to logon-page when someone is trying to edit passwords when not logged on git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@787 ab2d0c66-481e-0410-8bed-d214d4d58bed --- app/acf-util/password-controller.lua | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua index 333786a..fb78150 100755 --- a/app/acf-util/password-controller.lua +++ b/app/acf-util/password-controller.lua @@ -23,6 +23,17 @@ local function admin_permission() end end +local function check_logonstatus(self) + -- Redirect the user if he's not logged in. + if not (self.sessiondata.userinfo) then + self.conf.action = "logon" + self.conf.controller = "logon" + self.conf.type = "redir" + error (self.conf) + return self + end +end + local function get_config(self,userid) local config = {} local userinfo = {} @@ -82,6 +93,10 @@ local function get_config(self,userid) end function status(self) + + -- Redirect the user if he's not logged in. + check_logonstatus(self) + local status = {} -- Check for admin persmissions - else redirect to personal options @@ -154,10 +169,14 @@ function status(self) value="Create", -- disabled="yes", }) - return { status=status } + return { status=status } end function administrator(self) + + -- Redirect the user if he's not logged in. + check_logonstatus(self) + local output = {} -- Check for admin persmissions - else redirect to personal options @@ -192,7 +211,8 @@ end function edit_me(self) - -- FIXME: Redirect to Welcome or logon if user is not logged on + -- Redirect the user if he's not logged in. + check_logonstatus(self) -- Output userinfo local output = get_config(self,sessiondata.userinfo.userid) @@ -218,7 +238,7 @@ function edit_me(self) return {config=output} end -clientdata_from_roles = function(self) +local clientdata_from_roles = function(self) local output = {} for k,v in pairs(auth.list_roles()) do @@ -231,6 +251,9 @@ clientdata_from_roles = function(self) end function save(self) + -- Redirect the user if he's not logged in. + check_logonstatus(self) + local errormessage = {} local cmdresult = {} -- cgit v1.2.3