diff options
author | Natanael Copa <natanael.copa@gmail.com> | 2007-07-27 12:53:38 +0000 |
---|---|---|
committer | Natanael Copa <natanael.copa@gmail.com> | 2007-07-27 12:53:38 +0000 |
commit | dc53423183a0c459284ebd139022b707f01af006 (patch) | |
tree | 8a67a2904ec991028bddd429d57eec114b05baab /app/acf-util/logon-controller.lua | |
parent | 275c80281ba2e84b8d810bdb1c2b7f8c9a4333d9 (diff) | |
download | acf-core-dc53423183a0c459284ebd139022b707f01af006.tar.bz2 acf-core-dc53423183a0c459284ebd139022b707f01af006.tar.xz |
moved core files to new dir structurev2.0_alpha1
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@219 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'app/acf-util/logon-controller.lua')
-rw-r--r-- | app/acf-util/logon-controller.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/app/acf-util/logon-controller.lua b/app/acf-util/logon-controller.lua new file mode 100644 index 0000000..8359c18 --- /dev/null +++ b/app/acf-util/logon-controller.lua @@ -0,0 +1,60 @@ +-- Logon / Logoff functions + +module (..., package.seeall) + +require ("session") + +mvc.on_load = function(self, parent) + -- If they specify an invalid action or try to run init, then redirect + -- to the read function. + if ( self.conf.action == nil or self.conf.action == "init" ) then + -- do what? + end + +end + + +logon = function(self) + + local username=cfe({ name="username" }) + local password=cfe({ name="password" }) + local logon=cfe({ name="Logon", type="submit"}) + local s = "" + + if self.clientdata.username and self.clientdata.password then + if self.model.logon(self, self.clientdata.username, self.clientdata.password) == false then + username.value = self.clientdata.username + if self.session.id then + username.errtxt = "You are already logged in. Logout first." + else + username.errtxt = "There was a problem logging in" + end + else + self.conf.controller = "" + self.conf.action = "" + self.conf.prefix = "" + self.conf.type = "redir" + error(self.conf) + end + end + -- If we reach this point, just give them the login page + return ( cfe ({type="form", + option={ script=ENV["SCRIPT_NAME"], + prefix=self.conf.prefix, + controller = self.conf.controller, + action = "logon" }, + value = { username, password, logon } })) +end + + +logout = function(self) + self.model.logout(self, session.id) + + + -- and raise an error to go to the homepage + self.conf.action = "" + self.conf.prefix = "" + self.conf.controller = "" + self.conf.type = "redir" + error(self.conf) +end |