Merge pull request #663 from NeoRaider/styleable-checkboxes
[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(luci.http.getenv("REQUEST_URI"))%>">
10         <%- if fuser then %>
11         <div class="errorbox"><%:Invalid username and/or password! Please try again.%></div>
12         <% end -%>
13
14         <div class="cbi-map">
15                 <h2 name="content"><%:Authorization Required%></h2>
16                 <div class="cbi-map-descr">
17                         <%:Please enter your username and password.%>
18                 </div>
19                 <fieldset class="cbi-section"><fieldset class="cbi-section-node">
20                         <div class="cbi-value">
21                                 <label class="cbi-value-title"><%:Username%></label>
22                                 <div class="cbi-value-field">
23                                         <input class="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" />
24                                 </div>
25                         </div>
26                         <div class="cbi-value cbi-value-last">
27                                 <label class="cbi-value-title"><%:Password%></label>
28                                 <div class="cbi-value-field">
29                                         <input class="cbi-input-password" type="password" name="luci_password" />
30                                 </div>
31                         </div>
32                 </fieldset></fieldset>
33         </div>
34
35         <div>
36                 <input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
37                 <input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
38         </div>
39 </form>
40 <script type="text/javascript">//<![CDATA[
41         var input = document.getElementsByName('luci_password')[0];
42         if (input)
43                 input.focus();
44 //]]></script>
45
46 <%
47 local uci  = require "luci.model.uci".cursor()
48 local fs  = require "nixio.fs"
49 local https_key = uci:get("uhttpd", "main", "key")
50 local https_port = uci:get("uhttpd", "main", "listen_https")
51 if type(https_port) == "table" then
52         https_port = https_port[1]
53 end
54
55 if https_port and fs.access(https_key) then
56         https_port = https_port:match("(%d+)$")
57 %>
58
59 <script type="text/javascript">//<![CDATA[
60         if (document.location.protocol != 'https:') {
61                 var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
62                 var img=new Image;
63                 img.onload=function(){window.location = url};
64                 img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
65                 setTimeout(function(){
66                         img.src=''
67                 }, 5000);
68         }
69 //]]></script>
70
71 <% end %>
72
73 <%+footer%>