diff options
-rw-r--r-- | i18n/english/luasrc/i18n/default.en.lua | 1 | ||||
-rw-r--r-- | i18n/german/luasrc/i18n/default.de.lua | 1 | ||||
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 2 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/value.htm | 2 | ||||
-rw-r--r-- | modules/admin-full/luasrc/controller/admin/system.lua | 2 | ||||
-rw-r--r-- | modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua | 44 | ||||
-rw-r--r-- | modules/admin-full/luasrc/view/admin_system/passwd.htm | 49 |
7 files changed, 49 insertions, 52 deletions
diff --git a/i18n/english/luasrc/i18n/default.en.lua b/i18n/english/luasrc/i18n/default.en.lua index ac532743b..81c5c25ea 100644 --- a/i18n/english/luasrc/i18n/default.en.lua +++ b/i18n/english/luasrc/i18n/default.en.lua @@ -92,6 +92,7 @@ services = "Services" settings = "Settings" start = "Start" static = "static" +status = "Status" statistics = "Statistics" submit = "Submit" syslog = "System Log" diff --git a/i18n/german/luasrc/i18n/default.de.lua b/i18n/german/luasrc/i18n/default.de.lua index a9c68cfbb..339f2e96b 100644 --- a/i18n/german/luasrc/i18n/default.de.lua +++ b/i18n/german/luasrc/i18n/default.de.lua @@ -94,6 +94,7 @@ settings = "Einstellungen" start = "Start" static = "statisch" statistics = "Statistiken" +status = "Status" submit = "Absenden" syslog = "Systemprotokoll" system = "System" diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 8816b11b7..3b5a7c1b7 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -653,7 +653,7 @@ function AbstractValue.parse(self, section) local cvalue = self:cfgvalue(section) if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI - fvalue = self:transform(self:validate(fvalue)) + fvalue = self:transform(self:validate(fvalue, section)) if not fvalue then self.tag_invalid[section] = true end diff --git a/libs/cbi/luasrc/view/cbi/value.htm b/libs/cbi/luasrc/view/cbi/value.htm index 777d48093..51c78549c 100644 --- a/libs/cbi/luasrc/view/cbi/value.htm +++ b/libs/cbi/luasrc/view/cbi/value.htm @@ -13,7 +13,7 @@ $Id$ -%> <%+cbi/valueheader%> - <input type="text" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section)) .. ifattr(self.size, "size") .. ifattr(self.maxlength, "maxlength") %> /> + <input type="<%=self.password and 'password" class="cbi-input-key' or "text"%>" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section)) .. ifattr(self.size, "size") .. ifattr(self.maxlength, "maxlength") %> /> <% if #self.keylist > 0 then -%> <script type="text/javascript"> cbi_combobox_init('<%=cbid%>', { 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 <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -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%> -<h1><%:system%></h1> -<h2><%:a_s_changepw%></h2> -<p><%:a_s_changepw1%></p> -<div><br /> -<% if stat then %> - <% if stat == 0 then %> - <code><%:a_s_changepw_changed%>!</code> - <% elseif stat == 10 then %> - <code class="error"><%:a_s_changepw_nomatch%>!</code> - <% else %> - <code class="error"><%:unknownerror%>!</code> - <% end %> -<% end %> -<% if not stat or stat == 10 then %> - <form method="post" action="<%=controller%>/admin/system/passwd"> - <div class="cbi-section-node"> - <div class="cbi-value"> - <div class="cbi-value-title"><%:password%></div> - <div class="cbi-value-field"><input type="password" name="pwd1" /></div> - </div> - <div class="cbi-value"> - <div class="cbi-value-title"><%:confirmation%></div> - <div class="cbi-value-field"><input type="password" name="pwd2" /></div> - </div> - <br /> - <div> - <input type="submit" value="<%:save%>" /> - <input type="reset" value="<%:reset%>" /> - </div> - </div> - </form> -<% end %> -</div> -<%+footer%>
\ No newline at end of file |