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

Commit

Permalink
Improvement of the fix for Google login issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fvulich committed Dec 11, 2019
1 parent 55351f6 commit 1a5ff9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/ux/Auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ Ext.define('Rambox.ux.Auth0', {

authWindow.loadURL(me.authService.requestAuthCode());

authWindow.webContents.on('did-start-loading', function(e) {
authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin']

googleLoginURLs.forEach((loginURL) => {
if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0' })
callback({ cancel: false, requestHeaders: details.requestHeaders });
});
});

authWindow.webContents.on('did-navigate', function(e, url) {
me.authService.requestAccessCode(url, me.onLogin.bind(me), authWindow);
});
Expand Down
6 changes: 4 additions & 2 deletions app/ux/WebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Ext.define('Rambox.ux.WebView',{
if ( !me.record.get('enabled') ) return;

var webview = me.getWebView();
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin']

// Google Analytics Event
ga_storage._trackEvent('Services', 'load', me.type, 1, true);
Expand All @@ -287,8 +288,7 @@ Ext.define('Rambox.ux.WebView',{
console.info('Start loading...', me.src);

webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => {
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin']
googleLoginURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'; })
googleLoginURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'})
callback({ cancel: false, requestHeaders: details.requestHeaders });
});

Expand Down Expand Up @@ -541,6 +541,8 @@ Ext.define('Rambox.ux.WebView',{
});
})
eventsOnDom = true;

googleLoginURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() })
}
webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) })
});
Expand Down

0 comments on commit 1a5ff9c

Please sign in to comment.