forked from taruntailor7/fraazo-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
37 lines (30 loc) · 855 Bytes
/
login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var users = JSON.parse(localStorage.getItem("user")) || [];
function login() {
event.preventDefault();
var email = document.getElementById("email").value;
var password = document.getElementById("pass").value;
var newUser = []; //
var flag = false;
for (var i = 0; i < users.length; i++) {
if (users[i].email === email && users[i].password === password) {
flag = true;
var userObj = {
name: users[i].name,
mobile: users[i].mobile,
};
// console.log(users[i].name);
// console.log(userObj);
newUser.push(userObj);
// console.log(newUser);
localStorage.setItem("userName",JSON.stringify(newUser));
break;
}
}
if(flag){
alert("Successfully Logged In !");
window.location.href ="./homepage.html";
}
else{
alert("Wrong Credentials !");
}
}