summaryrefslogtreecommitdiffstats
path: root/app/acf-util/logon-controller.lua
blob: 61b4864c12f78515775bb9050a7b5f020dc1eac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Logon / Logoff functions

module (..., package.seeall)

mvc = {}
mvc.on_load = function(self, parent)
	self.conf.default_action = "status"
end

-- Logon a new user based upon id and password in clientdata
logon = function(self)
	local cmdresult
	if clientdata.userid and clientdata.password then
		local logon = self.model:logon(clientdata, conf.clientip, conf.sessiondir, sessiondata)
		-- If successful logon, redirect to status, otherwise try again
		if logon then
			self.conf.action = "status"
			self.conf.type = "redir"
			error(self.conf)
		else
			cmdresult = "Logon Attempt Failed"
		end
	end
	return ({ cmdresult = cmdresult })
end

-- Log out current user and go to login screen
logout = function(self)
	local logout = self.model.logoff(conf.sessiondir, sessiondata)
	-- We have to redirect so a new session / menu is created
	self.conf.action = "logon"
	self.conf.type = "redir"
	error (self.conf)
end

-- Report the login status
status = function(self)
	return self.model.status(sessiondata)
end