diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-10-06 12:57:42 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-10-06 12:57:42 +0000 |
commit | 25c09923e08f664a0c791f27d521fb13f4d5d74c (patch) | |
tree | 6410b0964cdbbd2603b9598f8474b5a9333be520 /app/acf-util/password-model.lua | |
parent | b202af98292d6d7b5053e5a934b916153ce89af9 (diff) | |
download | acf-core-25c09923e08f664a0c791f27d521fb13f4d5d74c.tar.bz2 acf-core-25c09923e08f664a0c791f27d521fb13f4d5d74c.tar.xz |
Added home page (action) to user parameters and redirect there after login
Moved get_all_permissions function from acf-util/roles-model to lib/roles
Diffstat (limited to 'app/acf-util/password-model.lua')
-rw-r--r-- | app/acf-util/password-model.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/acf-util/password-model.lua b/app/acf-util/password-model.lua index b7e9ebe..e9e0cd6 100644 --- a/app/acf-util/password-model.lua +++ b/app/acf-util/password-model.lua @@ -3,7 +3,7 @@ module(..., package.seeall) require("authenticator") require("roles") -avail_roles, avail_skins = nil +avail_roles, avail_skins, avail_homes = nil local weak_password = function(password) -- If password is too short, return false @@ -19,7 +19,7 @@ end -- validate the settings (ignore password if it's nil) local validate_settings = function(settings) - -- Username, password, roles, and skin are allowed to not exist, just leave the same + -- Username, password, roles, skin, and home are allowed to not exist, just leave the same -- Set errtxt when entering invalid values if (#settings.value.userid.value == 0) then settings.value.userid.errtxt = "You need to enter a valid userid!" end if string.find(settings.value.userid.value, "[^%w_]") then settings.value.userid.errtxt = "Can only contain letters, numbers, and '_'" end @@ -36,6 +36,7 @@ local validate_settings = function(settings) end if settings.value.roles then modelfunctions.validatemulti(settings.value.roles) end if settings.value.skin then modelfunctions.validateselect(settings.value.skin) end + if settings.value.home then modelfunctions.validateselect(settings.value.home) end -- Return false if any errormessages are set for name,value in pairs(settings.value) do @@ -126,12 +127,23 @@ function read_user(self, user) end end + -- Call into ?? controller to get the list of home actions + if not avail_homes then + avail_homes = {""} + local tmp1, tmp2 = roles.get_all_permissions(self) + table.sort(tmp2) + for i,h in ipairs(tmp2) do + avail_homes[#avail_homes+1] = h + end + end + -- Passwords are set to empty string result.username = cfe({ value=userinfo.username or "", label="Real name" }) result.password = cfe({ value="", label="Password" }) result.password_confirm = cfe({ value="", label="Password (confirm)" }) result.roles = cfe({ type="multi", value=userinfo.roles or {}, label="Roles", option=avail_roles or {} }) result.skin = cfe({ type="select", value=userinfo.skin or "", label="Skin", option=avail_skins or {""} }) + result.home = cfe({ type="select", value=userinfo.home or "", label="Home", option=avail_homes or {""} }) return cfe({ type="group", value=result, label="User Config" }) end |