urgh
This commit is contained in:
@@ -5,45 +5,51 @@
|
||||
<title>MASI 3DSecure</title>
|
||||
|
||||
<style>
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
header, footer {
|
||||
background: #f4f4f4;
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#payment
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main>
|
||||
<input id="username-field" placeholder="Username">
|
||||
<br>
|
||||
<input id="password-field" placeholder="Password">
|
||||
<br>
|
||||
<button id="connect-button">Connect</button>
|
||||
<div id="login">
|
||||
<h2>Login</h2>
|
||||
<input id="username-field" placeholder="Username">
|
||||
<br>
|
||||
<input id="password-field" placeholder="Password">
|
||||
<br>
|
||||
<button id="connect-button">Connect</button>
|
||||
</div>
|
||||
<div id="payment">
|
||||
<h2>Payment</h2>
|
||||
<input id="amount-input" placeholder="Amount">
|
||||
<br>
|
||||
<button>Pay</button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
|
||||
function redirectToProtectedRoute(route) {
|
||||
let data = JSON.parse(localStorage.getItem("creds"));
|
||||
|
||||
fetch(route, {
|
||||
headers: {
|
||||
"Authorization": `Basic ${data.username}:${data.password}`
|
||||
}
|
||||
})
|
||||
.then(r => r.text())
|
||||
.then(html => document.body.innerHTML = html);
|
||||
}
|
||||
|
||||
let btn = document.getElementById("connect-button");
|
||||
btn.addEventListener("click", async () => {
|
||||
let username = document.getElementById("username-field").value;
|
||||
@@ -63,7 +69,7 @@
|
||||
.then(response => {
|
||||
if(response.ok) {
|
||||
localStorage.setItem("creds", JSON.stringify(data));
|
||||
redirectToProtectedRoute("/payment");
|
||||
document.getElementById("payment").style.display = 'block';
|
||||
} else {
|
||||
throw new Error("Authentication request failed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user