57 lines
1.7 KiB
HTML
57 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login Test</title>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
|
|
|
|
<script>
|
|
</script>
|
|
<script>
|
|
function hashPassword(password) {
|
|
return CryptoJS.SHA256(password).toString();
|
|
}
|
|
function loginUser() {
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
const data = {
|
|
username: username,
|
|
password: password
|
|
};
|
|
|
|
fetch('/ec_user/login/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(data)
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.error) {
|
|
alert('Error: ' + data.error);
|
|
} else {
|
|
alert('Success: ' + data.message);
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('Error:', error);
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h2>Login</h2>
|
|
<form onsubmit="event.preventDefault(); loginUser();">
|
|
<label for="username">Username:</label><br>
|
|
<input type="text" id="username" name="username" required><br>
|
|
<label for="password">Password:</label><br>
|
|
<input type="password" id="password" name="password" required><br><br>
|
|
<input type="submit" value="Login">
|
|
</form>
|
|
</body>
|
|
</html>
|