mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
fix auth dropbox
This commit is contained in:
parent
bdac16ee24
commit
2669a3e8ad
@ -338,11 +338,12 @@ export class DropboxAuthModal extends Modal {
|
|||||||
k.verifier,
|
k.verifier,
|
||||||
authCode
|
authCode
|
||||||
);
|
);
|
||||||
|
const self = this;
|
||||||
setConfigBySuccessfullAuthInplace(
|
setConfigBySuccessfullAuthInplace(
|
||||||
this.plugin.settings.dropbox,
|
this.plugin.settings.dropbox,
|
||||||
authRes
|
authRes,
|
||||||
|
() => self.plugin.saveSettings()
|
||||||
);
|
);
|
||||||
const self = this;
|
|
||||||
const client = new RemoteClient(
|
const client = new RemoteClient(
|
||||||
"dropbox",
|
"dropbox",
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -229,9 +229,10 @@ export const sendRefreshTokenReq = async (
|
|||||||
return resp2;
|
return resp2;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setConfigBySuccessfullAuthInplace = (
|
export const setConfigBySuccessfullAuthInplace = async (
|
||||||
config: DropboxConfig,
|
config: DropboxConfig,
|
||||||
authRes: DropboxSuccessAuthRes
|
authRes: DropboxSuccessAuthRes,
|
||||||
|
saveUpdatedConfigFunc: () => Promise<any> | undefined
|
||||||
) => {
|
) => {
|
||||||
console.log("start updating local info of Dropbox token");
|
console.log("start updating local info of Dropbox token");
|
||||||
|
|
||||||
@ -247,6 +248,10 @@ export const setConfigBySuccessfullAuthInplace = (
|
|||||||
config.accountID = authRes.account_id;
|
config.accountID = authRes.account_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saveUpdatedConfigFunc !== undefined) {
|
||||||
|
await saveUpdatedConfigFunc();
|
||||||
|
}
|
||||||
|
|
||||||
console.log("finish updating local info of Dropbox token");
|
console.log("finish updating local info of Dropbox token");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -269,7 +274,7 @@ export class WrappedDropboxClient {
|
|||||||
init = async () => {
|
init = async () => {
|
||||||
if (
|
if (
|
||||||
this.dropboxConfig.accessToken === "" ||
|
this.dropboxConfig.accessToken === "" ||
|
||||||
this.dropboxConfig.username === ""
|
this.dropboxConfig.refreshToken === ""
|
||||||
) {
|
) {
|
||||||
throw Error("The user has not manually auth yet.");
|
throw Error("The user has not manually auth yet.");
|
||||||
}
|
}
|
||||||
@ -289,9 +294,11 @@ export class WrappedDropboxClient {
|
|||||||
this.dropboxConfig.refreshToken
|
this.dropboxConfig.refreshToken
|
||||||
);
|
);
|
||||||
|
|
||||||
setConfigBySuccessfullAuthInplace(this.dropboxConfig, resp);
|
setConfigBySuccessfullAuthInplace(
|
||||||
await this.saveUpdatedConfigFunc();
|
this.dropboxConfig,
|
||||||
|
resp,
|
||||||
|
this.saveUpdatedConfigFunc
|
||||||
|
);
|
||||||
this.dropbox = new Dropbox({
|
this.dropbox = new Dropbox({
|
||||||
accessToken: this.dropboxConfig.accessToken,
|
accessToken: this.dropboxConfig.accessToken,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user