Skip to content

Commit

Permalink
Fix electron's handler
Browse files Browse the repository at this point in the history
  • Loading branch information
JezerM committed Feb 2, 2022
1 parent 9f1a4b3 commit fe07e99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions ts/bridge/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export class Greeter {
if (started || this.is_authenticated) reset_screensaver();
return started;
} catch (err) {
console.log(err);
logger.error(err);
general_error_prompt(
browser.primary_window,
"LightDM couldn't start session",
Expand Down Expand Up @@ -738,14 +738,13 @@ function handler(
const param = args[0];
args.shift();
if (!hasKey(accesor, param)) return (ev.returnValue = undefined);
const pr = accesor[param];
const pr: unknown = accesor[param];
const ac = descriptors[param];
global.lightdm["respond"];

let value = undefined;

if (typeof pr === "function") {
const func: (...v: unknown[]) => unknown = Object.bind(pr, accesor);
const func: (...v: unknown[]) => unknown = pr.bind(accesor);
value = func(...args);
} else {
if (args.length > 0 && ac && ac.set) {
Expand All @@ -754,6 +753,12 @@ function handler(
value = pr || undefined;
}
}
//console.log({
//accesor: accesor.constructor.name,
//result: value,
//args,
//param,
//});
return (ev.returnValue = value);
}

Expand Down
8 changes: 6 additions & 2 deletions ts/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Browser {
const req_url = request.url;
const url = new URL(req_url);
const res = decodeURI(url.pathname);
//console.log({ url, res });
//console.error("Protocol:", { url, res });
callback(res);
});
}
Expand Down Expand Up @@ -266,13 +266,17 @@ class Browser {

session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
const url = new URL(details.url);
//console.log({ origin: details.url, url });
const block =
!(
url.protocol.includes("web-greeter") ||
url.protocol.includes("file") ||
url.protocol.includes("devtools")
) && nody_greeter.config.greeter.secure_mode;
//console.error("BeforeRequest:", {
//origin: details.url,
//url,
//blocked: block,
//});
callback({ cancel: block });
});
}
Expand Down

0 comments on commit fe07e99

Please sign in to comment.