All GCC vendors and employee details for IT department management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org" lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>GCC Tapal Details Management - Login</title>
  7. <!-- CSRF Tokens -->
  8. <meta th:if="${_csrf != null}" name="_csrf" th:content="${_csrf.token}" />
  9. <meta th:if="${_csrf != null}" name="_csrf_header" th:content="${_csrf.headerName}" />
  10. <!-- Include CSS -->
  11. <link rel="stylesheet" type="text/css" th:href="@{/assets/css/login-form-styles.css}">
  12. <!-- Awesome Font -->
  13. <link th:href="@{/assets/font-awesome-6.5.2/css/all.min.css}" rel="stylesheet" type="text/css">
  14. </head>
  15. <body>
  16. <div class="container">
  17. <img th:src="@{/assets/header-images/gcc1.png}" alt="Greater Chennai Corporation" class="small-logo">
  18. <h3>GREATER CHENNAI CORPORATION</h3>
  19. <h4>பெருநகர சென்னை மாநகராட்சி</h4>
  20. <br>
  21. <h3>GCC Tapal Details Management</h3>
  22. <br>
  23. <h2>Login</h2>
  24. <div id="error-box"
  25. style="color: #c0392b; font-weight: 500; font-size: 0.85rem; margin-bottom: 1.5rem; text-align: center; display: none;">
  26. <i class="fa-solid fa-circle-exclamation"></i> <span id="error-text">Invalid username or password!</span>
  27. </div>
  28. <form id="loginForm" onsubmit="handleLogin(event)">
  29. <div class="input-field">
  30. <input type="text" name="usrName" id="usrName" placeholder="Enter Username" required
  31. autocomplete="username">
  32. <div class="underline"></div>
  33. </div>
  34. <div class="input-field">
  35. <input type="password" name="usrPass" id="usrPass" placeholder="Enter Password" required
  36. autocomplete="current-password">
  37. <div class="underline"></div>
  38. </div>
  39. <input type="submit" value="Login" id="submit-btn">
  40. </form>
  41. </div>
  42. <!-- Footer Fragment -->
  43. <th:block th:replace="~{fragments/footer :: footer}"></th:block>
  44. <!-- Custom JS -->
  45. <script th:inline="javascript">
  46. const contextPath = /*[[@{/}]]*/ '';
  47. </script>
  48. <script>
  49. function handleLogin(event) {
  50. event.preventDefault();
  51. const errorBox = document.getElementById("error-box");
  52. const errorText = document.getElementById("error-text");
  53. const submitBtn = document.getElementById("submit-btn");
  54. errorBox.style.display = "none";
  55. submitBtn.disabled = true;
  56. submitBtn.value = 'Authenticating...';
  57. const username = document.getElementById("usrName").value;
  58. const password = document.getElementById("usrPass").value;
  59. const urlParams = new URLSearchParams();
  60. urlParams.append('usrName', username);
  61. urlParams.append('usrPass', password);
  62. // Fetch CSRF tokens
  63. const csrfToken = document.querySelector("meta[name='_csrf']")?.getAttribute("content");
  64. const csrfHeader = document.querySelector("meta[name='_csrf_header']")?.getAttribute("content");
  65. const headers = {
  66. 'Content-Type': 'application/x-www-form-urlencoded'
  67. };
  68. if (csrfToken && csrfHeader) {
  69. headers[csrfHeader] = csrfToken;
  70. }
  71. fetch(contextPath + 'gcctapaldetailsmanagement/api/login', {
  72. method: 'POST',
  73. headers: headers,
  74. body: urlParams
  75. })
  76. .then(response => response.json())
  77. .then(data => {
  78. if (data.result) {
  79. //alert("username: " + data.usrName + "usrPass:" + data.password);
  80. sessionStorage.setItem("tap_usrName", data.usrName);
  81. window.location.href = contextPath + 'gcctapaldetailsmanagement/dashboard';
  82. } else {
  83. submitBtn.disabled = false;
  84. submitBtn.value = 'Login';
  85. errorText.textContent = data.error || "Authentication failed.";
  86. errorBox.style.display = "block";
  87. }
  88. })
  89. .catch(err => {
  90. console.error("Login Error:", err);
  91. submitBtn.disabled = false;
  92. submitBtn.value = 'Login';
  93. errorText.textContent = "Network error. Please try again later.";
  94. errorBox.style.display = "block";
  95. });
  96. }
  97. </script>
  98. </body>
  99. </html>