Преглед на файлове

fixed issue when authInfo is null

Former-commit-id: 2526f68ab9df092f39c6a592c434cbb95e1a0a72
Gildas преди 6 години
родител
ревизия
49c4f45bc9
променени са 2 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 2 2
      extension/core/bg/downloads.js
  2. 9 3
      lib/gdrive/gdrive.js

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

@@ -140,9 +140,9 @@ singlefile.extension.core.bg.downloads = (() => {
 
 	async function getAuthInfo(force) {
 		let code, cancelled, authInfo = await singlefile.extension.core.bg.config.getAuthInfo();
-		const options = { interactive: true, auto: true };
 		gDrive.setAuthInfo(authInfo);
-		if (force || gDrive.managedToken()) {
+		const options = { interactive: true, auto: true };
+		if (!authInfo || force || gDrive.managedToken()) {
 			try {
 				if (options.auto && !gDrive.managedToken()) {
 					singlefile.extension.core.bg.tabs.getAuthCode(gDrive.getAuthURL(options))

+ 9 - 3
lib/gdrive/gdrive.js

@@ -63,9 +63,15 @@ this.GDrive = this.GDrive || (() => {
 		}
 		setAuthInfo(authInfo) {
 			if (!browser.identity.getAuthToken) {
-				this.accessToken = authInfo.accessToken;
-				this.refreshToken = authInfo.refreshToken;
-				this.expirationDate = authInfo.expirationDate;
+				if (authInfo) {
+					this.accessToken = authInfo.accessToken;
+					this.refreshToken = authInfo.refreshToken;
+					this.expirationDate = authInfo.expirationDate;
+				} else {
+					delete this.accessToken;
+					delete this.refreshToken;
+					delete this.expirationDate;
+				}
 			}
 		}
 		getAuthURL(options = {}) {