From 1e96668e4806fff9d60be987e6baafe57ba8fac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Kr=C4=8Dek?= Date: Wed, 30 Jul 2025 16:54:17 +0200 Subject: [PATCH] Fix signout and redesign auth step --- src/lib/components/wizard/StepAuth.svelte | 191 +++++++++++++--------- src/lib/google.ts | 34 +++- 2 files changed, 144 insertions(+), 81 deletions(-) diff --git a/src/lib/components/wizard/StepAuth.svelte b/src/lib/components/wizard/StepAuth.svelte index 32013dd..39cb1aa 100644 --- a/src/lib/components/wizard/StepAuth.svelte +++ b/src/lib/components/wizard/StepAuth.svelte @@ -1,80 +1,123 @@
-
-
-
- - - - -
- -

- Connect to Google -

- -

- Sign in with your Google account to access your Google Sheets and Google Drive for photo downloads. -

- -
-

Required permissions:

-

• View your Google Spreadsheets

-

• View and manage the files in your Google Drive

-
-
+
+

Connect to Google

+

+ Sign in with your Google account to access your Google Sheets and Google Drive for photo + downloads. +

+
- {#if $isSignedIn} - -
-
- - - - Authenticated -
- -

- You are signed in. -

- -
- - - -
-
- {:else} - - - {/if} -
+
+ +
+
+

Google Sheets Integration

+

+ Seamlessly import your data without the hassle of manual copy-pasting. +

+
+
+

Google Drive Access

+

+ Automatically download photos for your cards directly from your Google Drive. +

+
+
+

Privacy & Security

+

+ Your data is processed entirely in your browser. Nothing is ever uploaded to or stored on + our servers. We only request read-only access. All of the data is then removed from your browser + when the work is finished. +

+
+
+ + +
+ {#if $isSignedIn} + +
+
+ + + +

Successfully Connected

+
+

You are signed in and ready to proceed.

+ +
+ {:else} + +
+

Ready to Connect?

+

+ Click the button below to sign in with your Google account. +

+ +
+ {/if} +
+
+ +
diff --git a/src/lib/google.ts b/src/lib/google.ts index 8a5dfe2..afa487c 100644 --- a/src/lib/google.ts +++ b/src/lib/google.ts @@ -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) {