[OpenWrt-Devel] [PATCH] [luci] Autologin if root password is empty, to improve UX flow on first access.

2014-05-15 Thread Gui Iribarren
Current experience is at the very least confusing,
first there's a (otherwise useful) warning dialog, with a link
that (unless you login beforehand) only rewrites the url
but shows the same login page; 
where you're supposed to just push enter, but
with no instructions whatsoever.

Get rid of this intermediate step,
with a conditional javascript form.submit()

Signed-off-by: nicoechaniz nicoecha...@altermundi.net
Tested-by: Gui Iribarren g...@altermundi.net
---
 modules/admin-core/luasrc/view/sysauth.htm | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/admin-core/luasrc/view/sysauth.htm 
b/modules/admin-core/luasrc/view/sysauth.htm
index 7c39f0d..a3c7e69 100644
--- a/modules/admin-core/luasrc/view/sysauth.htm
+++ b/modules/admin-core/luasrc/view/sysauth.htm
@@ -13,7 +13,7 @@ You may obtain a copy of the License at
 
 %+header%
 
-form method=post action=%=pcdata(luci.http.getenv(REQUEST_URI))%
+form name=login method=post 
action=%=pcdata(luci.http.getenv(REQUEST_URI))%
div class=cbi-map
h2a id=content name=content%:Authorization 
Required%/a/h2
div class=cbi-map-descr
@@ -50,6 +50,12 @@ You may obtain a copy of the License at
input.focus();
 //]]/script
 
+%- if luci.sys.process.info(uid) == 0 and luci.sys.user.getuser(root) and 
not luci.sys.user.getpasswd(root) then -%
+script type=text/javascript//![CDATA[
+   document.login.submit()
+//]]/script
+%- end -%
+
 %
 local uci  = require luci.model.uci.cursor()
 local fs  = require nixio.fs
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] [luci] Autologin if root password is empty, to improve UX flow on first access.

2014-05-15 Thread Rafał Miłecki
On 16 May 2014 04:23, Gui Iribarren g...@altermundi.net wrote:
 +script type=text/javascript//![CDATA[
 +   document.login.submit()
 +//]]/script

I've no idea if this idea is going to be accepted, but *do not* use
document.all in your scripts. Seriously. It was an *ugly* hack
commonly used years ago (more than 10). Be specific when looking for
elements in DOM.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel