Reaperxxxx commited on
Commit
b22799f
·
verified ·
1 Parent(s): 457171c

Update public/index.html

Browse files
Files changed (1) hide show
  1. public/index.html +23 -22
public/index.html CHANGED
@@ -152,31 +152,32 @@
152
  }
153
 
154
  async function submitKey() {
155
- const userKey = document.getElementById("keyInput").value;
156
- if (userKey) {
157
- // Send the key to the server to validate
158
- try {
159
- const res = await fetch('/validate-key', {
160
- method: 'POST',
161
- headers: { 'Content-Type': 'application/json' },
162
- body: JSON.stringify({ key: userKey })
163
- });
164
-
165
- if (res.ok) {
166
- // Key is valid, hide the input form and load chat list
167
- keyInputContainer.style.display = 'none'; // Hide key input
168
- loadChatList();
169
- } else {
170
- alert("Invalid key. Please try again.");
171
- }
172
- } catch (error) {
173
- console.error('Error verifying key:', error);
174
- alert("Error verifying the key.");
175
- }
176
  } else {
177
- alert("Please enter a valid key.");
178
  }
 
 
 
179
  }
 
 
 
 
180
 
181
  socket.on('new_message', (newMessage) => {
182
  const currentChats = Array.from(chatList.children).map(chat => ({
 
152
  }
153
 
154
  async function submitKey() {
155
+ const userKey = document.getElementById("keyInput").value;
156
+ console.log("Key Sent to Server:", userKey); // Debugging line
157
+ if (userKey) {
158
+ // Send the key to the server to validate
159
+ try {
160
+ const res = await fetch('/validate-key', {
161
+ method: 'POST',
162
+ headers: { 'Content-Type': 'application/json' },
163
+ body: JSON.stringify({ key: userKey })
164
+ });
165
+
166
+ if (res.ok) {
167
+ // Key is valid, hide the input form and load chat list
168
+ keyInputContainer.style.display = 'none'; // Hide key input
169
+ loadChatList();
 
 
 
 
 
 
170
  } else {
171
+ alert("Invalid key. Please try again.");
172
  }
173
+ } catch (error) {
174
+ console.error('Error verifying key:', error);
175
+ alert("Error verifying the key.");
176
  }
177
+ } else {
178
+ alert("Please enter a valid key.");
179
+ }
180
+ }
181
 
182
  socket.on('new_message', (newMessage) => {
183
  const currentChats = Array.from(chatList.children).map(chat => ({