login.system 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="robots" content="noindex" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <title>ArozOS - Login</title>
  8. <link rel="stylesheet" href="script/tocas/tocas.css">
  9. <link rel="stylesheet" href="script/ao.css">
  10. <script type="application/javascript" src="script/tocas/tocas.js"></script>
  11. <script type="application/javascript" src="script/jquery.min.js"></script>
  12. <style>
  13. @media only screen and (max-height: 1000px) {
  14. .leftPictureFrame {
  15. height:auto !important;
  16. }
  17. }
  18. .leftPictureFrame{
  19. position:fixed;
  20. top:0px;
  21. left:0px;
  22. min-width:calc(100% - 500px);
  23. min-height:100%;
  24. background-color:#faf7eb;
  25. background-image:url("img/public/auth_bg.jpg");
  26. -webkit-background-size: cover;
  27. -moz-background-size: cover;
  28. -o-background-size: cover;
  29. background-size: cover;
  30. background-repeat: no-repeat, no-repeat;
  31. background-position:bottom left;
  32. }
  33. .rightLoginFrame{
  34. position:fixed;
  35. top:0;
  36. right:0;
  37. height:100%;
  38. width:500px;
  39. background-color:white;
  40. z-index:100%;
  41. padding-left: 30px;
  42. padding-right: 20px;
  43. }
  44. .fullHeightImage{
  45. height:100% !important;
  46. position:relative;
  47. left:-20px;
  48. }
  49. .bottombar{
  50. position:absolute;
  51. bottom:1em;
  52. left:0;
  53. padding-left: 20px;
  54. width:100%;
  55. }
  56. #animationFrame{
  57. position:absolute;
  58. bottom:0px;
  59. width:100%;
  60. }
  61. .textbox{
  62. margin-bottom:15px;
  63. }
  64. .loginbtn{
  65. color:white !important;
  66. margin-top:4em;
  67. }
  68. </style>
  69. </head>
  70. <body>
  71. <div class="leftPictureFrame">
  72. </div>
  73. <div id="loginInterface" class="rightLoginFrame">
  74. <br><br><br>
  75. <img class="ts medium image" src="data:image/png;base64, {{service_logo}}">
  76. <div class="ts borderless basic segment">
  77. <p><i class="key icon"></i> Sign in <span class="hostname">ArozOS</span> with your username and password</p>
  78. <br>
  79. <div class="ts fluid input textbox">
  80. <input id="username" type="text" placeholder="Username">
  81. </div>
  82. <div class="ts fluid input textbox">
  83. <input id="magic" type="password" placeholder="Password">
  84. </div>
  85. <div class="ts checkbox">
  86. <input id="rmbme" type="checkbox">
  87. <label for="rmbme">Remember Me</label>
  88. </div>
  89. <br>
  90. <button id="loginbtn" class="ts button loginbtn" style="background-color:#275d8c !important;">Sign In</button><br>
  91. <div class="ts breadcrumb" style="margin-top:12px;">
  92. <a class="section signup" style="cursor:pointer; display:none;" href="public/register/register.system">Sign Up</a>
  93. <div class="divider signup"> / </div>
  94. <a id="forgetpw" class="section" style="cursor:pointer" href="reset.system">Forgot Password</a>
  95. <div class="divider signin"> / </div>
  96. <a class="section signin" style="cursor:pointer; display:none;" href="system/auth/oauth/login">Signin via External account</a>
  97. </div>
  98. <p style="margin-top:18px;color:#ff7a70; display:none;font-size:1.2em;"><i class="remove icon"></i><span id="errmsg">Error. Incorrect username or password.</span></p>
  99. </div>
  100. <div class="bottombar">
  101. © ArOZ Online System (Go Edition) .feat <a href="http://imuslab.com">imuslab</a><br>
  102. <i class="disk outline icon"></i> Request Time: <span id="requestTime"></span>
  103. </div>
  104. </div>
  105. <script>
  106. var redirectionAddress = "{{redirection_addr}}";
  107. var systemUserCount = "{{usercount}}" - 0; //Magic way to convert string to int :)
  108. var isMobile = false; //initiate as false
  109. // device detection
  110. if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
  111. || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) {
  112. isMobile = true;
  113. }
  114. if (isMobile){
  115. //Full screen the login panel
  116. $("#loginInterface").css("width","100%");
  117. }
  118. if (systemUserCount == 0){
  119. //There are no user in this system yet. Rediect to user setup
  120. window.location.href = "/user.system";
  121. }
  122. $(document).ready(function(){
  123. var currentdate = new Date();
  124. var datetime = currentdate.getDate() + "/"
  125. + (currentdate.getMonth()+1) + "/"
  126. + currentdate.getFullYear() + " "
  127. + currentdate.getHours() + ":"
  128. + currentdate.getMinutes() + ":"
  129. + currentdate.getSeconds();
  130. $("#requestTime").text(datetime);
  131. //Check if the user already logged in
  132. $.get("system/auth/checkLogin",function(data){
  133. try{
  134. if (data === true || data.trim() == "true"){
  135. //User already logged in. Redirect to target page.
  136. if (redirectionAddress == ""){
  137. //Redirect back to index
  138. window.location.href = "/";
  139. }else{
  140. console.log(data);
  141. //window.location.href = redirectionAddress;
  142. }
  143. }
  144. }catch(ex){
  145. //Assume not logged in
  146. console.log(data);
  147. }
  148. });
  149. //Check if the system is open for registry
  150. $.get("public/register/checkPublicRegister",function(data){
  151. if (data == true){
  152. $(".signup").show();
  153. }else{
  154. $(".signup").remove();
  155. }
  156. });
  157. //OAuth related code, check if system is open for ext login
  158. $.get("system/auth/oauth/checkoauth",function(data){
  159. if (data == true){
  160. $(".signin").show();
  161. }else{
  162. $(".signin").remove();
  163. }
  164. });
  165. if(get('redirect') != undefined){
  166. $(".section.signin").attr("href","system/auth/oauth/login?redirect=" + get('redirect'));
  167. }
  168. //Get the system hostname and replace the hostname fields
  169. $.get("system/info/getArOZInfo", function(data){
  170. document.title = data.HostName + " - Sign In"
  171. $(".hostname").text(data.HostName);
  172. });
  173. });
  174. //Event handlers for buttons
  175. $("#loginbtn").on("click",function(){
  176. login();
  177. });
  178. $("input").on("keydown",function(event){
  179. if (event.keyCode === 13) {
  180. event.preventDefault();
  181. if ($(this).attr("id") == "magic"){
  182. login();
  183. }else{
  184. //Fuocus to password field
  185. $("#magic").focus();
  186. }
  187. }
  188. });
  189. //Login system with the given username and password
  190. function login(){
  191. var username = $("#username").val();
  192. var magic = $("#magic").val();
  193. var rmbme = document.getElementById("rmbme").checked;
  194. $("input").addClass('disabled');
  195. $.post("/system/auth/login", {"username": username, "password": magic, "rmbme": rmbme}).done(function(data){
  196. if (data.error !== undefined){
  197. //Something went wrong during the login
  198. $("#errmsg").text(data.error);
  199. $("#errmsg").parent().slideDown('fast').delay(5000).slideUp('fast');
  200. }else{
  201. //Login succeed
  202. if (redirectionAddress == ""){
  203. //Redirect back to index
  204. window.location.href = "/";
  205. }else{
  206. window.location.href = redirectionAddress;
  207. }
  208. }
  209. $("input").removeClass('disabled');
  210. });
  211. }
  212. //https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
  213. function get(name){
  214. if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
  215. return decodeURIComponent(name[1]);
  216. }
  217. </script>
  218. </body>
  219. </html>