76 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html data-bs-theme="light" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Login</title>
<link rel="icon" type="image/png" href="static/img/shipit.png">
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css">
</head>
<body>
<div class="container" style="margin-top: 10rem;">
<div class="row">
<div class="col-md-10 col-lg-4 mx-auto">
<form id="loginForm">
<div class="form-outline mb-4">
<input type="email" id="form2Example1" name="email" class="form-control" />
<label class="form-label" for="form2Example1">Email address</label>
</div>
<div class="form-outline mb-4">
<input type="password" id="form2Example2" name="password" class="form-control" />
<label class="form-label" for="form2Example2">Password</label>
</div>
<button type="sumbit" class="btn btn-primary btn-block mb-4">Sign in</button>
</form>
</div>
</div>
</div>
<script src="static/bootstrap/js/bootstrap.min.js"></script>
<script>
function handleSubmit(event) {
event.preventDefault();
const form = document.getElementById('loginForm');
const formData = new FormData(form);
console.log(formData);
fetch('{{login_url}}', {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
const accessToken = data.access_token;
localStorage.setItem('accessToken', accessToken)
})
.catch(error => {
console.error('Login error:', error);
});
}
const loginForm = document.getElementById('loginForm');
loginForm.addEventListener('submit', handleSubmit);
</script>
</body>
</html>
<!-- <!DOCTYPE html>
<html>
<head>
<title>Login Example</title>
</head>
<body>
<form id="loginForm">
<input type="text" name="email" placeholder="email">
<input type="password" name="password" placeholder="Password">
<button type="submit">Login</button>
</form>
</body>
</html> -->