Skip to content

Commit

Permalink
gui: Open Cozy TOS in external browser (#2222)
Browse files Browse the repository at this point in the history
If the user decides to read our TOS during the on-boarding process,
opening them in the on-boarding window will prevent them to finish the
process as there is no way to go back to the OAuth dance.
Besides, these TOS are written in a PDF file rather than an HTML page
and does not seem to be readable within the OAuth webview.

To make sure the user can read the TOS and continue the on-boarding
process, we'll intercept navigation to PDF files and open the given
URLs in the external browser.
  • Loading branch information
taratatach authored Apr 21, 2022
1 parent c548556 commit 0f4450a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gui/js/onboarding.window.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { addFileManagerShortcut } = require('./shortcut')
const { dialog, session, BrowserView } = require('electron')
const { dialog, session, BrowserView, shell } = require('electron')
const autoLaunch = require('./autolaunch')
const defaults = require('./defaults')
const { translate } = require('./i18n')
Expand Down Expand Up @@ -95,6 +95,13 @@ module.exports = class OnboardingWM extends WindowManager {
})
this.oauthView.setBounds({ ...bounds, x: 0, y: 0 })
this.centerOnScreen(LOGIN_SCREEN_WIDTH, LOGIN_SCREEN_HEIGHT)

this.oauthView.webContents.on('will-navigate', (event, url) => {
if (url.endsWith('.pdf')) {
event.preventDefault()
shell.openExternal(url)
}
})
} catch (err) {
log.error({ err, url, sentry: true }, 'failed loading OAuth view')
}
Expand Down

0 comments on commit 0f4450a

Please sign in to comment.