diff options
author | Steven Barth <steven@midlink.org> | 2008-08-14 19:01:36 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-14 19:01:36 +0000 |
commit | 15e2e16c6d81633d0dede30e7411e6b224998029 (patch) | |
tree | 37d4ca0fc8ba728e9c8a549798303edc43ee4516 /modules/admin-full/luasrc/model/cbi/admin_system | |
parent | d915e6e1d7421f366ca61bf081b6ca0d29945ec1 (diff) |
Converted password change form to CBI model
Diffstat (limited to 'modules/admin-full/luasrc/model/cbi/admin_system')
-rw-r--r-- | modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua | 44 |
1 files changed, 44 insertions, 0 deletions
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 |