Reaperxxxx commited on
Commit
030b42d
·
verified ·
1 Parent(s): 189c642

Update public/index.html

Browse files
Files changed (1) hide show
  1. public/index.html +24 -14
public/index.html CHANGED
@@ -78,8 +78,13 @@
78
  document.getElementById("loginForm").addEventListener("submit", async (event) => {
79
  event.preventDefault();
80
 
81
- const username = document.getElementById("loginUsername").value;
82
- const password = document.getElementById("loginPassword").value;
 
 
 
 
 
83
 
84
  const response = await fetch("/login", {
85
  method: "POST",
@@ -87,12 +92,12 @@
87
  body: JSON.stringify({ username, password }),
88
  });
89
 
90
- const message = await response.text();
91
- alert(message);
92
-
93
  if (response.ok) {
94
- // Redirect to terminal page
95
- window.location.href = "/terminal.html";
 
 
 
96
  }
97
  });
98
 
@@ -100,8 +105,13 @@
100
  document.getElementById("signupForm").addEventListener("submit", async (event) => {
101
  event.preventDefault();
102
 
103
- const username = document.getElementById("signupUsername").value;
104
- const password = document.getElementById("signupPassword").value;
 
 
 
 
 
105
 
106
  const response = await fetch("/signup", {
107
  method: "POST",
@@ -109,12 +119,12 @@
109
  body: JSON.stringify({ username, password }),
110
  });
111
 
112
- const message = await response.text();
113
- alert(message);
114
-
115
  if (response.ok) {
116
- // Redirect to terminal page
117
- window.location.href = "/terminal.html";
 
 
 
118
  }
119
  });
120
  </script>
 
78
  document.getElementById("loginForm").addEventListener("submit", async (event) => {
79
  event.preventDefault();
80
 
81
+ const username = document.getElementById("loginUsername").value.trim();
82
+ const password = document.getElementById("loginPassword").value.trim();
83
+
84
+ if (!username || !password) {
85
+ alert("Both fields are required!");
86
+ return;
87
+ }
88
 
89
  const response = await fetch("/login", {
90
  method: "POST",
 
92
  body: JSON.stringify({ username, password }),
93
  });
94
 
 
 
 
95
  if (response.ok) {
96
+ alert("Login successful!");
97
+ window.location.href = "/terminal.html"; // Redirect to terminal page
98
+ } else {
99
+ const message = await response.text();
100
+ alert(`Login failed: ${message}`);
101
  }
102
  });
103
 
 
105
  document.getElementById("signupForm").addEventListener("submit", async (event) => {
106
  event.preventDefault();
107
 
108
+ const username = document.getElementById("signupUsername").value.trim();
109
+ const password = document.getElementById("signupPassword").value.trim();
110
+
111
+ if (!username || !password) {
112
+ alert("Both fields are required!");
113
+ return;
114
+ }
115
 
116
  const response = await fetch("/signup", {
117
  method: "POST",
 
119
  body: JSON.stringify({ username, password }),
120
  });
121
 
 
 
 
122
  if (response.ok) {
123
+ alert("Sign-up successful! Redirecting to terminal...");
124
+ window.location.href = "/terminal.html"; // Redirect to terminal page
125
+ } else {
126
+ const message = await response.text();
127
+ alert(`Sign-up failed: ${message}`);
128
  }
129
  });
130
  </script>