소스 검색

fixed revoke token

Former-commit-id: 38827f025ca45f34590cc276317a386e71d33ae6
Gildas 6 년 전
부모
커밋
3f52f6ca87
2개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 4
      extension/core/bg/downloads.js
  2. 2 1
      extension/lib/gdrive/gdrive.js

+ 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;
 	}