rithwikreal commited on
Commit
ee36313
·
verified ·
1 Parent(s): 27a247e

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +40 -6
script.js CHANGED
@@ -1,7 +1,41 @@
1
- function openVoiceAgent() {
2
- window.open(
3
- "https://app.openhome.xyz/api/personalities/demo?token=AI-vMsEx",
4
- "_blank",
5
- "width=400,height=600"
6
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
 
1
+ // Redirect if not logged in
2
+ if (window.location.pathname.includes("app.html")) {
3
+ if (!localStorage.getItem("loggedInUser")) {
4
+ window.location.href = "index.html";
5
+ }
6
+ }
7
+
8
+ // Signup
9
+ function signup() {
10
+ const user = username.value;
11
+ const pass = password.value;
12
+
13
+ if (!user || !pass) {
14
+ message.innerText = "Please fill all fields";
15
+ return;
16
+ }
17
+
18
+ localStorage.setItem(user, pass);
19
+ message.innerText = "Signup successful! You can now login.";
20
+ }
21
+
22
+ // Login
23
+ function login() {
24
+ const user = username.value;
25
+ const pass = password.value;
26
+
27
+ const storedPass = localStorage.getItem(user);
28
+
29
+ if (storedPass === pass) {
30
+ localStorage.setItem("loggedInUser", user);
31
+ window.location.href = "app.html";
32
+ } else {
33
+ message.innerText = "Invalid credentials ❌";
34
+ }
35
+ }
36
+
37
+ // Logout
38
+ function logout() {
39
+ localStorage.removeItem("loggedInUser");
40
+ window.location.href = "index.html";
41
  }