luci-base, luci-app-firewall: port custom rules to client side view
[project/luci.git] / modules / luci-base / luasrc / view / sysauth.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
4 Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%+header%>
8
9 <form method="post" action="<%=pcdata(FULL_REQUEST_URI)%>">
10 <%- if fuser then %>
11 <div class="alert-message warning">
12 <p><%:Invalid username and/or password! Please try again.%></p>
13 </div>
14 <% end -%>
15
16 <div class="cbi-map">
17 <h2 name="content"><%:Authorization Required%></h2>
18 <div class="cbi-map-descr">
19 <%:Please enter your username and password.%>
20 </div>
21 <div class="cbi-section"><div class="cbi-section-node">
22 <div class="cbi-value">
23 <label class="cbi-value-title"><%:Username%></label>
24 <div class="cbi-value-field">
25 <input class="cbi-input-text" type="text" name="luci_username" value="<%=duser%>" />
26 </div>
27 </div>
28 <div class="cbi-value cbi-value-last">
29 <label class="cbi-value-title"><%:Password%></label>
30 <div class="cbi-value-field">
31 <input class="cbi-input-text" type="password" name="luci_password" />
32 </div>
33 </div>
34 </div></div>
35 </div>
36
37 <div class="cbi-page-actions">
38 <input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
39 <input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
40 </div>
41 </form>
42 <script type="text/javascript">//<![CDATA[
43 var input = document.getElementsByName('luci_password')[0];
44 if (input)
45 input.focus();
46 //]]></script>
47
48 <%
49 local uci = require "luci.model.uci".cursor()
50 local fs = require "nixio.fs"
51 local https_key = uci:get("uhttpd", "main", "key")
52 local https_port = uci:get("uhttpd", "main", "listen_https")
53 if type(https_port) == "table" then
54 https_port = https_port[1]
55 end
56
57 if https_port and fs.access(https_key) then
58 https_port = https_port:match("(%d+)$")
59 %>
60
61 <script type="text/javascript">//<![CDATA[
62 if (document.location.protocol != 'https:') {
63 var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
64 var img=new Image;
65 img.onload=function(){window.location = url};
66 img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
67 setTimeout(function(){
68 img.src=''
69 }, 5000);
70 }
71 //]]></script>
72
73 <% end %>
74
75 <%+footer%>