Fix signout and redesign auth step
This commit is contained in:
@@ -81,13 +81,33 @@ export function handleSignIn() {
|
||||
}
|
||||
|
||||
export function handleSignOut() {
|
||||
const token = gapi.client.getToken();
|
||||
if (token !== null) {
|
||||
google.accounts.oauth2.revoke(token.access_token, () => {
|
||||
gapi.client.setToken(null);
|
||||
isSignedIn.set(false);
|
||||
});
|
||||
}
|
||||
const savedToken = localStorage.getItem(TOKEN_KEY);
|
||||
if (savedToken) {
|
||||
try {
|
||||
const tokenData = JSON.parse(savedToken);
|
||||
if (tokenData.access_token) {
|
||||
google.accounts.oauth2.revoke(tokenData.access_token, () => {
|
||||
console.log('User token revoked.');
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error parsing token from localStorage', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Disables automatic sign-in on the next page load.
|
||||
google.accounts.id.disableAutoSelect();
|
||||
|
||||
// Clear gapi client token
|
||||
gapi.client.setToken(null);
|
||||
|
||||
// Clear token from localStorage
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
|
||||
// Update signed in state
|
||||
isSignedIn.set(false);
|
||||
|
||||
console.log('User signed out.');
|
||||
}
|
||||
|
||||
export async function searchSheets(query: string) {
|
||||
|
||||
Reference in New Issue
Block a user