From 15e2e16c6d81633d0dede30e7411e6b224998029 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Thu, 14 Aug 2008 19:01:36 +0000 Subject: Converted password change form to CBI model --- .../admin-full/luasrc/controller/admin/system.lua | 2 +- .../luasrc/model/cbi/admin_system/passwd.lua | 44 +++++++++++++++++++ .../admin-full/luasrc/view/admin_system/passwd.htm | 49 ---------------------- 3 files changed, 45 insertions(+), 50 deletions(-) create mode 100644 modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua delete mode 100644 modules/admin-full/luasrc/view/admin_system/passwd.htm (limited to 'modules') diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index a381803bb..cdf7ee2c6 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -20,7 +20,7 @@ function index() entry({"admin", "system"}, template("admin_system/index"), i18n("system"), 30) entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10) entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg"), i18n("a_s_p_ipkg")) - entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 20) + entry({"admin", "system", "passwd"}, form("admin_system/passwd"), i18n("a_s_changepw"), 20) entry({"admin", "system", "sshkeys"}, form("admin_system/sshkeys"), i18n("a_s_sshkeys"), 30) entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 40) entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50) diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua b/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua new file mode 100644 index 000000000..7e766d5eb --- /dev/null +++ b/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua @@ -0,0 +1,44 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +f = SimpleForm("password", translate("a_s_changepw"), translate("a_s_changepw1")) + +pw1 = f:field(Value, "pw1", translate("password")) +pw1.password = true + +pw2 = f:field(Value, "pw2", translate("confirmation")) +pw2.password = true + +function pw2.validate(self, value, section) + return pw1:formvalue(section) == value and value +end + +function f.handle(self, state, data) + if state == FORM_VALID then + local stat = luci.sys.user.setpasswd("root", data.pw1) == 0 + local x = f:field(DummyValue, "_stat") + + if stat then + x.value = translate("a_s_changepw_changed") + else + x.value = translate("unknownerror") + end + + pw1.render = function() end + pw2.render = pw1.render + end + return true +end + +return f \ No newline at end of file diff --git a/modules/admin-full/luasrc/view/admin_system/passwd.htm b/modules/admin-full/luasrc/view/admin_system/passwd.htm deleted file mode 100644 index 176abaea2..000000000 --- a/modules/admin-full/luasrc/view/admin_system/passwd.htm +++ /dev/null @@ -1,49 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth -Copyright 2008 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> -<%+header%> -

<%:system%>

-

<%:a_s_changepw%>

-

<%:a_s_changepw1%>

-

-<% if stat then %> - <% if stat == 0 then %> - <%:a_s_changepw_changed%>! - <% elseif stat == 10 then %> - <%:a_s_changepw_nomatch%>! - <% else %> - <%:unknownerror%>! - <% end %> -<% end %> -<% if not stat or stat == 10 then %> -
-
-
-
<%:password%>
-
-
-
-
<%:confirmation%>
-
-
-
-
- - -
-
-
-<% end %> -
-<%+footer%> \ No newline at end of file -- cgit v1.2.3