login.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>DezuKVM | Login</title>
  6. <meta name="csrf_token" content="">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <link rel="icon" type="image/png" href="/favicon.png">
  9. <style>
  10. html, body {
  11. height: 100%;
  12. margin: 0;
  13. padding: 0;
  14. font-family: Arial, Helvetica, sans-serif;
  15. }
  16. body {
  17. height: 100vh;
  18. display: flex;
  19. align-items: center;
  20. justify-content: center;
  21. background: #f5f5f5;
  22. color: #222;
  23. }
  24. .login-container {
  25. background: #fff;
  26. padding: 2rem 2.5rem;
  27. border-radius: 8px;
  28. box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  29. min-width: 420px;
  30. display: flex;
  31. flex-direction: column;
  32. align-items: center;
  33. }
  34. @media (prefers-color-scheme: dark) {
  35. body {
  36. background: #181a1b !important;
  37. color: #f1f1f1 !important;
  38. }
  39. .login-container {
  40. background: #23272a;
  41. box-shadow: 0 2px 16px rgba(0,0,0,0.32);
  42. }
  43. .login-container .error-message {
  44. background: #3a2323;
  45. color: #ffb3b3;
  46. border-color: #a94442;
  47. }
  48. input, .ui.input > input {
  49. background: #181a1b !important;
  50. color: #f1f1f1 !important;
  51. border-color: #444 !important;
  52. }
  53. .ui.basic.button {
  54. background: #23272a !important;
  55. color: #f1f1f1 !important;
  56. border-color: #444 !important;
  57. }
  58. .ui.basic.button:hover,
  59. .ui.basic.button:focus {
  60. background: #181a1b !important;
  61. color: #fff !important;
  62. border-color: #666 !important;
  63. }
  64. }
  65. .login-container form {
  66. width: 100%;
  67. display: flex;
  68. flex-direction: column;
  69. gap: 1rem;
  70. }
  71. .login-container .error-message {
  72. margin-top: 1rem;
  73. color: #d32f2f;
  74. background: #ffeaea;
  75. border: 1px solid #f5c6cb;
  76. border-radius: 4px;
  77. padding: 0.5rem;
  78. width: 100%;
  79. text-align: center;
  80. display: none;
  81. }
  82. </style>
  83. <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
  84. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.4/semantic.min.css" integrity="sha512-ySrYzxj+EI1e9xj/kRYqeDL5l1wW0IWY8pzHNTIZ+vc1D3Z14UDNPbwup4yOUmlRemYjgUXsUZ/xvCQU2ThEAw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  85. <script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.4/semantic.min.js" integrity="sha512-Y/wIVu+S+XJsDL7I+nL50kAVFLMqSdvuLqF2vMoRqiMkmvcqFjEpEgeu6Rx8tpZXKp77J8OUpMKy0m3jLYhbbw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  86. </head>
  87. <body>
  88. <div class="login-container ui basic segment">
  89. <img src="img/font_logo.svg" alt="dezuKVM Logo" style="width: 150px; margin-bottom: 1rem;">
  90. <p>Enter your password to access your IP-KVM</p>
  91. <form id="loginForm" autocomplete="off">
  92. <div class="ui action input" style="width:100%;">
  93. <input type="password" id="password" name="password" placeholder="Password" required autofocus>
  94. <button type="button" class="ui basic icon button" id="togglePassword" tabindex="-1">
  95. <i class="ui eye icon" id="eyeIcon"></i>
  96. </button>
  97. </div>
  98. <button class="ui basic button" type="submit"><i class="ui green sign in alternate icon"></i> Login</button>
  99. </form>
  100. <div style="width:100%; margin-top: 1rem; display: flex; justify-content: space-between; font-size: 0.95em;">
  101. <div>
  102. <div class="ui breadcrumb">
  103. <a href="/forgot-password" class="section">Forgot Password?</a>
  104. <div class="divider"> / </div>
  105. <a href="https://dezukvm.com" target="_blank" rel="noopener" class="section">DezuKVM</a>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="error-message" id="errorMsg"></div>
  110. </div>
  111. <script>
  112. // $cjax wrapper example (assumes similar to $.ajax)
  113. function $cjax(options) {
  114. var csrfToken = $('meta[name="csrf_token"]').attr('content');
  115. if (!options.headers) options.headers = {};
  116. options.headers['X-CSRF-Token'] = csrfToken;
  117. return $.ajax(options);
  118. }
  119. $(function() {
  120. $('#loginForm').on('submit', function(e) {
  121. e.preventDefault();
  122. $('#errorMsg').hide();
  123. var password = $('#password').val();
  124. $cjax({
  125. url: '/api/v1/login',
  126. method: 'POST',
  127. contentType: 'application/json',
  128. data: JSON.stringify({ password: password }),
  129. success: function(resp, status, xhr) {
  130. if (xhr.status === 200 && !(resp && resp.error)) {
  131. window.location.href = 'index.html';
  132. } else {
  133. var msg = resp && resp.error ? resp.error : 'Login failed.';
  134. $('#errorMsg').text(msg).show();
  135. }
  136. },
  137. error: function(xhr) {
  138. var msg = 'Login failed.';
  139. if (xhr.responseJSON && xhr.responseJSON.error) {
  140. msg = xhr.responseJSON.error;
  141. }
  142. $('#errorMsg').text(msg).show();
  143. }
  144. });
  145. });
  146. });
  147. $('#togglePassword').on('click', function() {
  148. var input = $('#password');
  149. var icon = $('#eyeIcon');
  150. if (input.attr('type') === 'password') {
  151. input.attr('type', 'text');
  152. icon.removeClass('eye').addClass('eye slash');
  153. } else {
  154. input.attr('type', 'password');
  155. icon.removeClass('eye slash').addClass('eye');
  156. }
  157. });
  158. </script>
  159. </body>
  160. </html>