From: Steven Barth Date: Thu, 14 Aug 2008 16:11:49 +0000 (+0000) Subject: Fixed login form X-Git-Tag: 0.8.0~434 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=36717208f1ae73290d352d706425e32f9726ff37 Fixed login form Converted SSH-Keys to CBI-Map --- diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index f7725c534..399f48675 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -268,7 +268,7 @@ function SimpleForm.parse(self, ...) or valid and 1 or -1 - self.dorender = self:handle(state) + self.dorender = self:handle(state, self.data) end function SimpleForm.render(self, ...) diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm index 8933016d7..a5a6046a5 100644 --- a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm +++ b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm @@ -17,7 +17,9 @@ $Id$ <%:help%>
<%=self.description%>
<%- end %> + <%- if self.title and #self.title > 0 then -%> + <%- end -%> <% if self.tag_invalid[section] then -%>
<%:cbi_invalid%>
diff --git a/libs/cbi/luasrc/view/cbi/full_valueheader.htm b/libs/cbi/luasrc/view/cbi/full_valueheader.htm index 5b890ed0b..ddc256dc7 100644 --- a/libs/cbi/luasrc/view/cbi/full_valueheader.htm +++ b/libs/cbi/luasrc/view/cbi/full_valueheader.htm @@ -14,9 +14,11 @@ $Id$ -%>
"> + <%- if self.title and #self.title > 0 then -%>
+ <%- end -%> diff --git a/libs/cbi/luasrc/view/cbi/simpleform.htm b/libs/cbi/luasrc/view/cbi/simpleform.htm index 38df61b5f..68c8cc916 100644 --- a/libs/cbi/luasrc/view/cbi/simpleform.htm +++ b/libs/cbi/luasrc/view/cbi/simpleform.htm @@ -17,7 +17,6 @@ $Id$
-

<%=self.title%>

@@ -32,12 +31,12 @@ $Id$
<%- if self.submit ~= false then %> - <% end %> <%- if self.reset ~= false then %> - <% end %> diff --git a/libs/cbi/luasrc/view/cbi/tvalue.htm b/libs/cbi/luasrc/view/cbi/tvalue.htm index 6a1396886..4d92545ae 100644 --- a/libs/cbi/luasrc/view/cbi/tvalue.htm +++ b/libs/cbi/luasrc/view/cbi/tvalue.htm @@ -13,7 +13,7 @@ $Id$ -%> <%+cbi/valueheader%> - <%+cbi/valuefooter%> diff --git a/modules/admin-core/luasrc/view/sysauth.htm b/modules/admin-core/luasrc/view/sysauth.htm index 236ec7e6a..e48f414c5 100644 --- a/modules/admin-core/luasrc/view/sysauth.htm +++ b/modules/admin-core/luasrc/view/sysauth.htm @@ -14,27 +14,36 @@ $Id$ -%> <%+header%> <% luci.i18n.loadc("sysauth") %> -

<%:sysauth_head%>

-

<%:sysauth_prompt%>

-<% if fuser then %> -
<%:sysauth_failed%>
-
-<% end %> +
-
+
+

<%:sysauth_head%>

+
+ <%:sysauth_prompt%> + <%- if fuser then %> +
<%:sysauth_failed%>
+
+ <% end -%> +
+
-
<%:username%>
-
+ +
+ +
-
<%:password%>
-
+ +
+ +
-
-
- - -
-
+ +
+ +
+ + +
<%+footer%> \ No newline at end of file diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index fec652699..cf39483cf 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -21,7 +21,7 @@ function index() entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10) entry({"admin", "system", "packages", "ipkg"}, call("action_ipkg"), i18n("a_s_p_ipkg")) entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 20) - entry({"admin", "system", "sshkeys"}, call("action_sshkeys"), i18n("a_s_sshkeys"), 30) + 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) entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60) @@ -220,24 +220,6 @@ function action_reboot() end end -function action_sshkeys() - local file = "/etc/dropbear/authorized_keys" - local data = luci.http.formvalue("data") - local stat = nil - local err = nil - - if data then - stat, err = luci.fs.writefile(file, data) - end - - local cnt = luci.fs.readfile(file) - if cnt then - cnt = luci.util.pcdata(cnt) - end - - luci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err}) -end - function action_upgrade() require("luci.model.uci") diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua b/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua new file mode 100644 index 000000000..a204d420f --- /dev/null +++ b/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua @@ -0,0 +1,34 @@ +--[[ +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$ +]]-- +local keyfile = "/etc/dropbear/authorized_keys" + +f = SimpleForm("sshkeys", translate("a_s_sshkeys"), translate("a_s_sshkeys1")) + +t = f:field(TextValue, "keys") +t.rows = 10 +function t.cfgvalue() + return luci.fs.readfile(keyfile) or "" +end + +function f.handle(self, state, data) + if state == FORM_VALID then + if (luci.fs.readfile(keyfile) or "") ~= data.keys then + luci.fs.writefile(keyfile, data.keys) + end + end + return true +end + +return f \ No newline at end of file diff --git a/modules/admin-full/luasrc/view/admin_system/sshkeys.htm b/modules/admin-full/luasrc/view/admin_system/sshkeys.htm deleted file mode 100644 index 7b636090c..000000000 --- a/modules/admin-full/luasrc/view/admin_system/sshkeys.htm +++ /dev/null @@ -1,39 +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%> - -
-
-

<%:a_s_sshkeys%>

-
- <%:a_s_sshkeys1%> -
-
- <%:a_s_sshkeys%> - - <% if msg then -%> -
<%:error%>: <%=msg%>
- <% end %> -
-
- -
- - -
-
- -<%+footer%>