2024-06-13 13:57:02 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Login</title>
|
2024-06-24 08:50:18 +00:00
|
|
|
{% include 'head.html' %}
|
2024-06-13 13:57:02 +00:00
|
|
|
</head>
|
2024-06-24 08:50:18 +00:00
|
|
|
<body class="login-body">
|
|
|
|
<div class="login-div">
|
|
|
|
<form class="login-form" id="login-form" method="POST">
|
|
|
|
<img class="login-img" src="{{ url_for('static', filename='images/ms-style-logo.svg') }}" alt="Image">
|
|
|
|
<h2 class="login-h2">Sign in</h2>
|
|
|
|
<div class="login-input-div-first">
|
|
|
|
<input class="login-input" type="text" class="form-control" id="username" name="username" placeholder="Username" required autocomplete="off">
|
2024-06-14 09:35:53 +00:00
|
|
|
</div>
|
2024-06-24 08:50:18 +00:00
|
|
|
<div class="login-input-div-rest">
|
|
|
|
<input class="login-input" type="password" class="form-control" id="password" name="password" placeholder="Password" required autocomplete="off">
|
|
|
|
</div>
|
|
|
|
<div class="login-input-div-first !flex-row">
|
|
|
|
<p class="no-account">No account? </p><a class="no-account no-account-button" href="{{ url_for('register') }}"> Create one!</a>
|
|
|
|
</div>
|
|
|
|
<div id="error-message" style="color: red; margin-top: 10px;"></div>
|
|
|
|
<div class="login-input-div-first items-end">
|
|
|
|
<button class="ms-button-signin" type="submit" class="btn btn-primary">Next</button>
|
2024-06-14 09:35:53 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2024-06-24 08:50:18 +00:00
|
|
|
<!-- <div class="ms-p !w-[440px] !h-fit bg-white relative top-2 p-3 pl-10 pr-10 !flex-row !justify-start items-center">
|
|
|
|
<i class="fa-solid fa-key text-black pr-2"></i>
|
|
|
|
<p class="text-black text-sm">Sign-in options</p>
|
|
|
|
</div> -->
|
2024-06-14 09:35:53 +00:00
|
|
|
<script>
|
2024-06-24 08:50:18 +00:00
|
|
|
document.getElementById('login-form').addEventListener('submit', function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
const form = event.target;
|
|
|
|
const formData = new FormData(form);
|
2024-06-14 09:35:53 +00:00
|
|
|
|
2024-06-24 08:50:18 +00:00
|
|
|
// Convert username to lowercase
|
|
|
|
const username = formData.get('username').toLowerCase();
|
|
|
|
formData.set('username', username);
|
|
|
|
|
|
|
|
axios.post('/login', formData)
|
|
|
|
.then(response => {
|
|
|
|
if (response.data.status === 'success') {
|
|
|
|
window.location.href = '/dashboard';
|
|
|
|
} else if (response.data.message === 'Account Disabled. Contact Support') {
|
|
|
|
alert('Account Disabled. Contact Support');
|
|
|
|
} else {
|
|
|
|
alert('Invalid credentials. Please try again.');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error logging in:', error);
|
|
|
|
alert('An error occurred. Please try again.');
|
2024-06-14 09:35:53 +00:00
|
|
|
});
|
2024-06-24 08:50:18 +00:00
|
|
|
});
|
|
|
|
|
2024-06-14 09:35:53 +00:00
|
|
|
</script>
|
2024-06-13 13:57:02 +00:00
|
|
|
</body>
|
|
|
|
</html>
|