Fix signout and redesign auth step
All checks were successful
Build Docker image / build (push) Successful in 3m14s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 1m8s

This commit is contained in:
Roman Krček
2025-07-30 16:54:17 +02:00
parent 923300e49b
commit 1e96668e48
2 changed files with 144 additions and 81 deletions

View File

@@ -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) {