e87f26c2c8a8d6302265daefc7e04c4492a6ce45
[project/luci.git] / modules / luci-base / luasrc / view / sysauth.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008-2012 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 -%>
13
14 <%+header%>
15
16 <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
17         <div class="cbi-map">
18                 <h2><a id="content" name="content"><%:Authorization Required%></a></h2>
19                 <div class="cbi-map-descr">
20                         <%:Please enter your username and password.%>
21                         <%- if fuser then %>
22                         <div class="error"><%:Invalid username and/or password! Please try again.%></div>
23                         <br />
24                         <% end -%>
25                 </div>
26                 <fieldset class="cbi-section"><fieldset class="cbi-section-node">
27                         <div class="cbi-value">
28                                 <label class="cbi-value-title"><%:Username%></label>
29                                 <div class="cbi-value-field">
30                                         <input class="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" />
31                                 </div>
32                         </div>
33                         <div class="cbi-value cbi-value-last">
34                                 <label class="cbi-value-title"><%:Password%></label>
35                                 <div class="cbi-value-field">
36                                         <input class="cbi-input-password" type="password" name="luci_password" />
37                                 </div>
38                         </div>
39                 </fieldset></fieldset>
40         </div>
41
42         <div>
43                 <input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
44                 <input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
45         </div>
46 </form>
47 <script type="text/javascript">//<![CDATA[
48         var input = document.getElementsByName('luci_password')[0];
49         if (input)
50                 input.focus();
51 //]]></script>
52
53 <%
54 local uci  = require "luci.model.uci".cursor()
55 local fs  = require "nixio.fs"
56 local https_key = uci:get("uhttpd", "main", "key")
57 local https_port = uci:get("uhttpd", "main", "listen_https")
58 if type(https_port) == "table" then
59         https_port = https_port[1]
60 end
61
62 if https_port and fs.access(https_key) then
63         https_port = https_port:match("(%d+)$")
64 %>
65
66 <script type="text/javascript">//<![CDATA[
67         if (document.location.protocol != 'https:') {
68                 var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
69                 var img=new Image;
70                 img.onload=function(){window.location = url};
71                 img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
72                 setTimeout(function(){
73                         img.src=''
74                 }, 5000);
75         }
76 //]]></script>
77
78 <% end %>
79
80 <%+footer%>