From 520ba28e7a281a39adc916687cb5428846f48421 Mon Sep 17 00:00:00 2001 From: ttrask Date: Fri, 20 Mar 2009 14:32:07 +0000 Subject: Removed built-in users alpine and foo from core, and instead redirect to create new user when none exist. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1738 ab2d0c66-481e-0410-8bed-d214d4d58bed --- app/acf-util/logon-controller.lua | 11 +++++++++++ app/acf-util/logon-model.lua | 3 +++ app/acf-util/password-model.lua | 12 +++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/acf-util/logon-controller.lua b/app/acf-util/logon-controller.lua index 978ee8c..c8cd82a 100644 --- a/app/acf-util/logon-controller.lua +++ b/app/acf-util/logon-controller.lua @@ -6,6 +6,17 @@ default_action = "status" -- Logon a new user based upon id and password in clientdata logon = function(self) + -- If there are no users defined, add privileges and dispatch password/newuser + local users = self.model:list_users() + if #users.value == 0 then + self.sessiondata.permissions.password = {} + self.sessiondata.permissions.password.newuser = {"temp"} + self:dispatch(self.conf.prefix, "password", "newuser") + self.sessiondata.permissions.password = nil + self.conf.suppress_view = true + return + end + local userid = cfe({ value=clientdata.userid or "", label="User ID" }) local password = cfe({ label="Password" }) local redir = cfe({ value=clientdata.redir or "/welcome/read", label="" }) diff --git a/app/acf-util/logon-model.lua b/app/acf-util/logon-model.lua index b817cf9..c110ee6 100644 --- a/app/acf-util/logon-model.lua +++ b/app/acf-util/logon-model.lua @@ -57,3 +57,6 @@ logon = function (self, userid, password, ip_addr, sessiondir, sessiondata) return cfe({ type="boolean", value=false, label="Logon Success" }) end +list_users = function(self) + return cfe({ type="list", value=authenticator.list_users(self), label="Users" }) +end diff --git a/app/acf-util/password-model.lua b/app/acf-util/password-model.lua index 87c2e6f..fb06fae 100755 --- a/app/acf-util/password-model.lua +++ b/app/acf-util/password-model.lua @@ -7,7 +7,17 @@ function create_user(self, userdata) end function read_user(self, user) - return authenticator.get_userinfo(self, user) + local retval = authenticator.get_userinfo(self, user) + if not user then + local userlist = authenticator.list_users(self) + if #userlist == 0 then + -- There are no users yet, suggest some values + retval.value.userid.value = "root" + retval.value.username.value = "Admin account" + retval.value.roles.value = {"ADMIN"} + end + end + return retval end function update_user(self, userdata) -- cgit v1.2.3