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:
parent
2e8fe88f53
commit
bd73107853
@ -41,10 +41,13 @@ class OneDriveLoginScreenComponent extends React.Component {
|
||||
const url = event.url;
|
||||
|
||||
if (this.authCode_) return;
|
||||
if (url.indexOf(this.redirectUrl() + '?code=') !== 0) return;
|
||||
|
||||
let code = url.split('?code=');
|
||||
this.authCode_ = code[1];
|
||||
const urlParse = require('url').parse;
|
||||
const parsedUrl = urlParse(url.trim(), true);
|
||||
|
||||
if (!('code' in parsedUrl.query)) return;
|
||||
|
||||
this.authCode_ = parsedUrl.query.code;
|
||||
|
||||
try {
|
||||
await reg.syncTarget().api().execTokenRequest(this.authCode_, this.redirectUrl(), true);
|
||||
@ -53,7 +56,7 @@ class OneDriveLoginScreenComponent extends React.Component {
|
||||
} catch (error) {
|
||||
bridge().showMessageBox({
|
||||
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'),
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user