mirror of
https://github.com/aykhans/portfolio-blog.git
synced 2025-07-05 10:42:36 +00:00
- login route changed from login to secret key
- Edited login.html
This commit is contained in:
@ -1,41 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html data-bs-theme="light" lang="en">
|
||||
|
||||
<head>
|
||||
<title>Login Example</title>
|
||||
<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>
|
||||
<form id="loginForm">
|
||||
<!-- Your login input fields go here -->
|
||||
<input type="text" name="email" placeholder="email">
|
||||
<input type="password" name="password" placeholder="Password">
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
<div class="container" style="margin-top: 10rem;">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-lg-4 mx-auto">
|
||||
<form>
|
||||
<div class="form-outline mb-4">
|
||||
<input type="email" id="form2Example1" class="form-control" />
|
||||
<label class="form-label" for="form2Example1">Email address</label>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Function to handle the form submission
|
||||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
const form = document.getElementById('loginForm');
|
||||
const formData = new FormData(form);
|
||||
<div class="form-outline mb-4">
|
||||
<input type="password" id="form2Example2" class="form-control" />
|
||||
<label class="form-label" for="form2Example2">Password</label>
|
||||
</div>
|
||||
|
||||
fetch('/login', {
|
||||
method: 'POST', // Adjust the HTTP method if needed
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const accessToken = data.access_token;
|
||||
console.log(accessToken);
|
||||
document.cookie = `access_token=${accessToken}`;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Login error:', error);
|
||||
});
|
||||
}
|
||||
<button type="button" class="btn btn-primary btn-block mb-4">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
// Add a submit event listener to the form
|
||||
const loginForm = document.getElementById('loginForm');
|
||||
loginForm.addEventListener('submit', handleSubmit);
|
||||
</script>
|
||||
<script src="static/bootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user