1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Electron: Improved parsing of auth token

This commit is contained in:
Laurent Cozic 2017-11-28 21:36:04 +00:00
parent 2e8fe88f53
commit bd73107853

View File

@ -41,10 +41,13 @@ class OneDriveLoginScreenComponent extends React.Component {
const url = event.url; const url = event.url;
if (this.authCode_) return; if (this.authCode_) return;
if (url.indexOf(this.redirectUrl() + '?code=') !== 0) return;
let code = url.split('?code='); const urlParse = require('url').parse;
this.authCode_ = code[1]; const parsedUrl = urlParse(url.trim(), true);
if (!('code' in parsedUrl.query)) return;
this.authCode_ = parsedUrl.query.code;
try { try {
await reg.syncTarget().api().execTokenRequest(this.authCode_, this.redirectUrl(), true); await reg.syncTarget().api().execTokenRequest(this.authCode_, this.redirectUrl(), true);
@ -53,7 +56,7 @@ class OneDriveLoginScreenComponent extends React.Component {
} catch (error) { } catch (error) {
bridge().showMessageBox({ bridge().showMessageBox({
type: 'error', type: 'error',
message: error.message, message: 'Could not login to OneDrive. Please try again.\n\n' + error.message + "\n\n" + url.match(/.{1,64}/g).join('\n'),
}); });
} }