Procházet zdrojové kódy

fixed revoke token

Former-commit-id: 38827f025ca45f34590cc276317a386e71d33ae6
Gildas před 6 roky
rodič
revize
3f52f6ca87

+ 2 - 4
extension/core/bg/downloads.js

@@ -111,10 +111,8 @@ singlefile.extension.core.bg.downloads = (() => {
 		}
 		if (message.method.endsWith(".disableGDrive")) {
 			const authInfo = await singlefile.extension.core.bg.config.getAuthInfo();
-			if (authInfo) {
-				singlefile.extension.core.bg.config.removeAuthInfo();
-				await gDrive.revokeAuthToken(authInfo.accessToken);
-			}
+			singlefile.extension.core.bg.config.removeAuthInfo();
+			await gDrive.revokeAuthToken(authInfo && (authInfo.accessToken || authInfo.revokableAccessToken));
 			return {};
 		}
 		if (message.method.endsWith(".end")) {

+ 2 - 1
extension/lib/gdrive/gdrive.js

@@ -54,6 +54,7 @@ this.GDrive = this.GDrive || (() => {
 			}
 			if (nativeAuth(options)) {
 				this.accessToken = await browser.identity.getAuthToken({ interactive: options.interactive });
+				return { revokableAccessToken: this.accessToken };
 			} else {
 				getAuthURL(this, options);
 				return options.code ? authFromCode(this, options) : initAuth(this, options);
@@ -243,7 +244,7 @@ this.GDrive = this.GDrive || (() => {
 		return gdrive.authURL;
 	}
 
-	function nativeAuth(options) {
+	function nativeAuth(options = {}) {
 		return Boolean(browser.identity && browser.identity.getAuthToken) && !options.forceWebAuthFlow;
 	}