This commit is contained in:
2025-12-05 23:56:58 +01:00
parent 7b03494e8b
commit 9e4d2a426f
2 changed files with 32 additions and 21 deletions

View File

@@ -5,45 +5,51 @@
<title>MASI 3DSecure</title> <title>MASI 3DSecure</title>
<style> <style>
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
header, footer { header, footer {
background: #f4f4f4; background: #f4f4f4;
padding: 15px; padding: 15px;
text-align: center; text-align: center;
} }
main { main {
padding: 20px; padding: 20px;
} }
#payment
{
display: none;
}
</style> </style>
</head> </head>
<body> <body>
<main> <main>
<input id="username-field" placeholder="Username"> <div id="login">
<br> <h2>Login</h2>
<input id="password-field" placeholder="Password"> <input id="username-field" placeholder="Username">
<br> <br>
<button id="connect-button">Connect</button> <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> </main>
<script> <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"); let btn = document.getElementById("connect-button");
btn.addEventListener("click", async () => { btn.addEventListener("click", async () => {
let username = document.getElementById("username-field").value; let username = document.getElementById("username-field").value;
@@ -63,7 +69,7 @@
.then(response => { .then(response => {
if(response.ok) { if(response.ok) {
localStorage.setItem("creds", JSON.stringify(data)); localStorage.setItem("creds", JSON.stringify(data));
redirectToProtectedRoute("/payment"); document.getElementById("payment").style.display = 'block';
} else { } else {
throw new Error("Authentication request failed") throw new Error("Authentication request failed")
} }

View File

@@ -23,12 +23,17 @@
<body> <body>
<main> <main>
<h1>Payment page</h1>
<input id="amount-input" placeholder="Amount">
<button>Pay</button>
</main> </main>
<script> <script>
let btn = document.getElementById("btn-back");
console.log("Clicked");
btn.addEventListener("click", () => {
console.log("Clicked");
window.location.href = "/";
});
</script> </script>
</body> </body>