mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Create person_model.js
This commit is contained in:
61
frontend/vanilla/html/login.html
Normal file
61
frontend/vanilla/html/login.html
Normal file
@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>HTML5 Login Form with validation Example</title>
|
||||
<link rel="stylesheet" href="../css/login-register.css">
|
||||
</head>
|
||||
<body>
|
||||
<!-- partial:index.partial.html -->
|
||||
<div id="login-form-wrap">
|
||||
<h2>Login</h2>
|
||||
<form id="login-form" method="POST">
|
||||
|
||||
<p>
|
||||
<input type="email" id="email" name="email" placeholder="Email Address" required><i class="validation"><span></span><span></span></i>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="password" id="password" name="password" placeholder="Password" required><i class="validation"><span></span><span></span></i>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<button type="button" onclick="login()">Login</button>
|
||||
</p>
|
||||
</form>
|
||||
<div id="create-account-wrap">
|
||||
<p>Not a member? <a href="./register.html">Create Account</a><p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function login() {
|
||||
const email = document.getElementById("email").value;
|
||||
const password = document.getElementById("password").value;
|
||||
|
||||
if(!email || !password){
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
};
|
||||
|
||||
fetch('http://localhost:3000/blinkapi/login', options)
|
||||
.then(response => {})
|
||||
.then(data => {
|
||||
document.cookie = `token=${data.token};`;
|
||||
})
|
||||
.catch(err => {
|
||||
alert("An error has occurred :-( please try again later")
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user