Browse Source

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. 🤦‍♂️
Sam Atkins 1 year ago
parent
commit
776b6831f3
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/IPC.js

+ 2 - 2
src/IPC.js

@@ -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;
             }