mirror of https://github.com/keeweb/keeweb.git
fix #821: auto-click OneDrive popup login button if it's the only option
This commit is contained in:
parent
a6bd460469
commit
0e63e955ce
|
@ -146,9 +146,11 @@ _.extend(StorageBase.prototype, {
|
|||
.replace('{scope}', encodeURIComponent(opts.scope))
|
||||
.replace('{url}', encodeURIComponent(this._getOauthRedirectUrl()));
|
||||
this.logger.debug('OAuth: popup opened');
|
||||
if (!this._openPopup(url, 'OAuth', opts.width, opts.height)) {
|
||||
const popupWindow = this._openPopup(url, 'OAuth', opts.width, opts.height);
|
||||
if (!popupWindow) {
|
||||
return callback('OAuth: cannot open popup');
|
||||
}
|
||||
this._popupOpened(popupWindow);
|
||||
const popupClosed = () => {
|
||||
Backbone.off('popup-closed', popupClosed);
|
||||
window.removeEventListener('message', windowMessage);
|
||||
|
@ -177,6 +179,9 @@ _.extend(StorageBase.prototype, {
|
|||
window.addEventListener('message', windowMessage);
|
||||
},
|
||||
|
||||
_popupOpened(popupWindow) {
|
||||
},
|
||||
|
||||
_oauthProcessReturn: function(message) {
|
||||
const token = this._oauthMsgToToken(message);
|
||||
if (token && !token.error) {
|
||||
|
|
|
@ -239,6 +239,22 @@ const StorageOneDrive = StorageBase.extend({
|
|||
width: 600,
|
||||
height: 500
|
||||
};
|
||||
},
|
||||
|
||||
_popupOpened(popupWindow) {
|
||||
if (popupWindow.webContents) {
|
||||
popupWindow.webContents.on('did-finish-load', (e) => {
|
||||
const webContents = e.sender.webContents;
|
||||
const url = webContents.getURL();
|
||||
if (url && url.startsWith('https://login.microsoftonline.com/common/oauth2/v2.0/authorize')) {
|
||||
// click the login button mentioned in #821
|
||||
const script =
|
||||
`const selector = '[role="button"][aria-describedby="tileError loginHeader"]';
|
||||
if (document.querySelectorAll(selector).length === 1) document.querySelector(selector).click()`;
|
||||
webContents.executeJavaScript(script);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue