This repository has been archived on 2024-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
burgerauth/static/js/aeskeyshare.js

25 lines
818 B
JavaScript
Raw Normal View History

window.addEventListener("message", function(event) {
try {
let data = JSON.parse(event.data);
const access_token = data["access_token"];
const redirect_uri = data["redirect_uri"];
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");
}
});