Made aeskeyshare work properly

This commit is contained in:
Tracker-Friendly 2024-04-29 21:18:46 +01:00
parent 8299915502
commit 6e87268930
2 changed files with 15 additions and 22 deletions

View File

@ -1,24 +1,17 @@
// Add an event listener to handle incoming messages
window.addEventListener("message", function(event) {
try {
let data = JSON.parse(event.data);
const access_token = data["access_token"];
const redirect_uri = data["redirect_uri"];
const access_token = event.data;
fetch("https://auth.hectabit.org/api/isloggedin", {
method: "POST",
body: JSON.stringify({
access_token: access_token
})
fetch("https://auth.hectabit.org/api/isloggedin", {
method: "POST",
body: JSON.stringify({
access_token: access_token
})
.then((response) => {
if (response.status === 200) {
console.log("Key is valid");
let newtab = window.open(redirect_uri);
newtab.postMessage(localStorage.getItem("DONOTSHARE-password"), "*");
window.close();
}
});
} catch {
console.log("Error parsing JSON");
}
});
})
.then((response) => function () {
if (response.status === 200) {
console.log("Key is valid")
window.postMessage(localStorage.getItem("DONOTSHARE-password"), event.origin)
}
})
});

View File

@ -7,5 +7,5 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="icon" href="/static/svg/favicon.svg">
</head>
<p>Redirecting...</p>
<p>Sending key...</p>
<script src="/static/js/aeskeyshare.js"></script>