Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit a520ca4

Browse files
committed
fix:login logout button click issue
1 parent 7ba24c5 commit a520ca4

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/common/integrations/GoogleDrive.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ class GoogleDriveUtil {
8585
};
8686

8787
login = () => {
88-
gapi.client.setToken('');
89-
this.client.callback = response => {
90-
this.accessToken = response.access_token;
91-
localStorage.setItem('accessToken', this.accessToken);
92-
this.updateLoginStatus(true);
93-
};
94-
this.client.requestAccessToken({ prompt: '' });
88+
if (!this.accessToken) {
89+
gapi.client.setToken('');
90+
this.client.callback = response => {
91+
this.accessToken = response.access_token;
92+
localStorage.setItem('accessToken', this.accessToken);
93+
this.updateLoginStatus(true);
94+
};
95+
this.client.requestAccessToken({ prompt: '' });
96+
}
9597
};
9698

9799
updateLoginStatus(isLoggedIn) {
@@ -100,13 +102,15 @@ class GoogleDriveUtil {
100102
}
101103

102104
logout = () => {
103-
this.updateLoginStatus(false);
104-
if (localStorage.getItem('accessToken')) localStorage.removeItem('accessToken');
105105
if (this.accessToken) {
106-
gapi.client.setToken('');
107-
google.accounts.oauth2.revoke(this.accessToken);
106+
this.updateLoginStatus(false);
107+
if (localStorage.getItem('accessToken')) localStorage.removeItem('accessToken');
108+
if (this.accessToken) {
109+
gapi.client.setToken('');
110+
google.accounts.oauth2.revoke(this.accessToken);
111+
}
112+
this.accessToken = '';
108113
}
109-
this.accessToken = '';
110114
};
111115

112116
listFiles = async () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy