-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
99 lines (81 loc) · 2.76 KB
/
login.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<html lang="en">
<head>
<title>Login</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body class="img js-fullheight">
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="card">
<form onsubmit="event.preventDefault()" class="box">
<h1>Login</h1>
<p > Please enter your login and password!</p>
<input id="email" type="text" name="" placeholder="E-mail">
<input id="pass" type="password" name="" placeholder="Password">
<div class="container">
<a class="forgot " href="#">Forgot password?</a>
<a style="margin-left: 10px;" class="btn btn-primary" href="register.html">Sign Up</a>
</div><br>
<input id="submit" type="submit" name="" value="Login" href="#">
<!-- <div class="col-md-12">
<ul class="social-network social-circle">
<li><a href="#" class="icoFacebook" title="Facebook"><i
class="fab fa-facebook-f"></i></a></li>
<li><a href="#" class="icoTwitter" title="Twitter"><i class="fab fa-twitter"></i></a>
</li>
<li><a href="#" class="icoGoogle" title="Google +"><i
class="fab fa-google-plus"></i></a></li>
</ul>
</div> -->
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
const api_url = "https://reqres.in/api/login";
document.getElementById("submit").addEventListener("click", function (event) {
const email = document.getElementById("email").value;
const pass = document.getElementById("pass").value;
event.preventDefault()
if (email == "" || pass == "") {
alert("please fill Email And Password");
return false;
}
getUser(email, pass);
});
async function getUser(email, pass) {
const response = await fetch(api_url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
password: pass,
}),
});
let result = await response.json();
console.log(result);
if (!result.error) {
alert("Login success");
window.sessionStorage.setItem("token", result.token);
setTimeout(() => { window.location = "index.html" }, 500)
} else {
alert(result.error);
}
}
</script>
<script src="js/jquery.min.js"></script>
<script src="js/popper.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>