Fix permission check for closeApp message

Firstly, I was missing an `async` here, which somehow still worked for
me then, but produced errors for me when I tried it today.

Then, actually await the promise.

Finally, actually check the target's parent is us, and not just that it
has the attribute!

I don't know what was going on in my head that day. 🤦‍♂️
This commit is contained in:
Sam Atkins 2024-04-11 14:35:22 +01:00
parent eb66848aee
commit 776b6831f3

View File

@ -1116,9 +1116,9 @@ window.addEventListener('message', async (event) => {
}
// Check permissions
const allowed = (() => {
const allowed = await (async () => {
// Parents can close their children
if (target_window.dataset['parent_instance_id']) {
if (target_window.dataset['parent_instance_id'] === appInstanceID) {
console.log(`⚠️ Allowing app ${appInstanceID} to close child app ${targetAppInstanceID}`);
return true;
}