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

Commit 1a5ff9c

Browse files
committed
Improvement of the fix for Google login issues
1 parent 55351f6 commit 1a5ff9c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

app/ux/Auth0.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ Ext.define('Rambox.ux.Auth0', {
270270

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

273+
authWindow.webContents.on('did-start-loading', function(e) {
274+
authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
275+
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin']
276+
277+
googleLoginURLs.forEach((loginURL) => {
278+
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' })
279+
callback({ cancel: false, requestHeaders: details.requestHeaders });
280+
});
281+
});
282+
273283
authWindow.webContents.on('did-navigate', function(e, url) {
274284
me.authService.requestAccessCode(url, me.onLogin.bind(me), authWindow);
275285
});

app/ux/WebView.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ Ext.define('Rambox.ux.WebView',{
275275
if ( !me.record.get('enabled') ) return;
276276

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

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

289290
webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => {
290-
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin']
291-
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'; })
291+
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'})
292292
callback({ cancel: false, requestHeaders: details.requestHeaders });
293293
});
294294

@@ -541,6 +541,8 @@ Ext.define('Rambox.ux.WebView',{
541541
});
542542
})
543543
eventsOnDom = true;
544+
545+
googleLoginURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() })
544546
}
545547
webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) })
546548
});

0 commit comments

Comments
 (0)