sysauth.htm 2.2 KB

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