Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
🔒 Add a few recommended security safeguards
Browse files Browse the repository at this point in the history
  • Loading branch information
GitSquared committed Aug 12, 2018
1 parent 6355f38 commit 6007626
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/_boot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const signale = require("signale");
const {app, BrowserWindow, dialog} = require("electron");
const {app, BrowserWindow, dialog, shell} = require("electron");

process.on("uncaughtException", e => {
signale.fatal(e);
Expand Down Expand Up @@ -164,6 +164,18 @@ app.on('ready', () => {
signale.watch("Waiting for frontend connection...");
});

app.on('web-contents-created', (e, contents) => {
// Prevent creating more than one window
contents.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
// Prevent loading something else than the UI
contents.on('will-navigate', (e, url) => {
e.preventDefault();
});
});

app.on('window-all-closed', () => {
signale.info("All windows closed");
app.quit();
Expand Down

0 comments on commit 6007626

Please sign in to comment.