neowolves/auth-server/static/login.html

84 lines
2.5 KiB
HTML
Raw Normal View History

2024-01-15 18:51:51 +03:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="//code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
2024-01-17 18:33:59 +03:00
<style>
body {
background-color: black;
color: white;
}
2024-01-17 20:24:14 +03:00
2024-01-17 18:33:59 +03:00
label {
font-size: 20px;
}
2024-01-17 20:24:14 +03:00
2024-01-17 18:33:59 +03:00
input {
background-color: #282828;
border: none;
border-bottom: 1px solid white;
color: white;
font-size: 18px;
margin-bottom: 20px;
padding: 10px;
}
2024-01-17 20:24:14 +03:00
2024-01-17 18:33:59 +03:00
button {
background-color: #4CAF50;
border: none;
color: white;
font-size: 22px;
padding: 10px 20px;
margin-top: 20px;
}
2024-01-17 20:24:14 +03:00
2024-01-17 18:33:59 +03:00
button:hover {
background-color: #3e8e41;
}
</style>
2024-01-15 18:51:51 +03:00
</head>
<body>
2024-01-15 20:19:23 +03:00
<div class="container">
2024-01-17 18:33:59 +03:00
<h1>Login</h1>
<form>
2024-01-15 20:19:23 +03:00
<div class="form-group">
2024-01-17 18:33:59 +03:00
<label for="user_login">Username</label>
<input type="text" class="form-control" name="user_login" required placeholder="Enter your username">
2024-01-15 20:19:23 +03:00
</div>
<div class="form-group">
<label for="client_secret">Password</label>
2024-01-17 18:33:59 +03:00
<input type="password" class="form-control" name="client_secret" placeholder="Enter your password">
2024-01-15 20:19:23 +03:00
</div>
2024-01-17 18:33:59 +03:00
<button id="login-btn">Login</button>
2024-01-15 20:19:23 +03:00
</form>
</div>
2024-01-17 18:33:59 +03:00
<script>
const loginBtn = document.getElementById('login-btn');
loginBtn.addEventListener('click', (event) => {
event.preventDefault();
const userLogin = document.querySelector('input[name="user_login"]').value;
const clientSecret = document.querySelector('input[name="client_secret"]').value;
const backRedirectionAddress = new URLSearchParams(window.location.search).get('back_redirection_address');
2024-01-17 20:24:14 +03:00
fetch(`http://localhost:9096/login?client_id=${userLogin}&client_secret=${clientSecret}&scope=all&grant_type=client_credentials`)
2024-01-17 18:33:59 +03:00
.then(response => response.json())
.then(data => {
2024-01-17 20:24:14 +03:00
window.location.href = `https://${backRedirectionAddress}?access_token=${accessToken}&user_login=${userLogin}`;
2024-01-17 18:33:59 +03:00
})
.catch(error => console.error(error));
});
</script>
2024-01-15 18:51:51 +03:00
</body>
2024-01-15 20:19:23 +03:00
</html>
<style>
.btn-primary {
margin-top: 10px;
}
2024-01-15 20:58:19 +03:00
</style>