applications/ffwizard: Show password field only when it is the default (as in /rom/etc/passwd)
This commit is contained in:
parent
1805fb7b14
commit
7a5b6e34af
1 changed files with 14 additions and 28 deletions
|
@ -66,32 +66,22 @@ end
|
||||||
-------------------- View --------------------
|
-------------------- View --------------------
|
||||||
f = SimpleForm("ffwizward", "Freifunkassistent",
|
f = SimpleForm("ffwizward", "Freifunkassistent",
|
||||||
"Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
|
"Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
|
||||||
-- main netconfig
|
|
||||||
local newpsswd = has_rom and sys.exec("diff /rom/etc/passwd /etc/passwd")
|
-- if password is not set or default then force the user to set a new one
|
||||||
if newpsswd ~= "" then
|
if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
|
||||||
pw = f:field(Flag, "pw", "Router Passwort", "Setzen Sie den Haken, um Ihr Passwort zu ändern.")
|
pw1 = f:field(Value, "pw1", translate("password"))
|
||||||
function pw.cfgvalue(self, section)
|
pw1.password = true
|
||||||
return 1
|
pw1.rmempty = false
|
||||||
|
|
||||||
|
pw2 = f:field(Value, "pw2", translate("confirmation"))
|
||||||
|
pw2.password = true
|
||||||
|
pw2.rmempty = false
|
||||||
|
|
||||||
|
function pw2.validate(self, value, section)
|
||||||
|
return pw1:formvalue(section) == value and value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pw1 = f:field(Value, "pw1", translate("password"))
|
|
||||||
pw1.password = true
|
|
||||||
pw1.rmempty = false
|
|
||||||
|
|
||||||
pw2 = f:field(Value, "pw2", translate("confirmation"))
|
|
||||||
pw2.password = true
|
|
||||||
pw2.rmempty = false
|
|
||||||
|
|
||||||
function pw2.validate(self, value, section)
|
|
||||||
return pw1:formvalue(section) == value and value
|
|
||||||
end
|
|
||||||
|
|
||||||
if newpsswd ~= "" then
|
|
||||||
pw1:depends("pw", "1")
|
|
||||||
pw2:depends("pw", "1")
|
|
||||||
end
|
|
||||||
|
|
||||||
net = f:field(ListValue, "net", "Freifunk Community", "Nutzen Sie die Einstellungen der Freifunk Gemeinschaft in ihrer Nachbarschaft.")
|
net = f:field(ListValue, "net", "Freifunk Community", "Nutzen Sie die Einstellungen der Freifunk Gemeinschaft in ihrer Nachbarschaft.")
|
||||||
net.rmempty = false
|
net.rmempty = false
|
||||||
net.optional = false
|
net.optional = false
|
||||||
|
@ -589,11 +579,7 @@ function f.handle(self, state, data)
|
||||||
else
|
else
|
||||||
if data.pw1 then
|
if data.pw1 then
|
||||||
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
|
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
|
||||||
-- if stat then
|
end
|
||||||
-- f.message = translate("a_s_changepw_changed")
|
|
||||||
-- else
|
|
||||||
-- f.errmessage = translate("unknownerror")
|
|
||||||
end
|
|
||||||
data.pw1 = nil
|
data.pw1 = nil
|
||||||
data.pw2 = nil
|
data.pw2 = nil
|
||||||
uci:commit("freifunk")
|
uci:commit("freifunk")
|
||||||
|
|
Loading…
Reference in a new issue