urgh
This commit is contained in:
@@ -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>
|
||||||
|
<div id="login">
|
||||||
|
<h2>Login</h2>
|
||||||
<input id="username-field" placeholder="Username">
|
<input id="username-field" placeholder="Username">
|
||||||
<br>
|
<br>
|
||||||
<input id="password-field" placeholder="Password">
|
<input id="password-field" placeholder="Password">
|
||||||
<br>
|
<br>
|
||||||
<button id="connect-button">Connect</button>
|
<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")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user