fix(web): redirect Google auth through callback#1723
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR changes Google authorization in Compass from a popup-based flow to a full-page redirect flow. Both Google sign-in/sign-up and “Connect Google Calendar” now leave Compass through Google and return through
/auth/google/callback.It also deepens the web-side Google authorization module so the redirect start, saved authorization intent, callback completion, scope validation, and return-path handling live behind one clearer module instead of being spread across the callback page and redirect helper files.
The PR also fixes a related local-data issue: seeded demo events are marked as demo-only in browser storage, so they do not get uploaded into a user’s real account when the user later signs in or connects Google.
Why This Changed
The previous Google flow relied on popup behavior and a looser redirect setup. That made the flow harder to reason about and left Compass depending on popup-specific cancellation/error handling.
This branch makes the Google authorization flow explicit:
/dayas the fallback.What Changed
Google authorization now uses a redirect callback
Google authorization now returns through
/auth/google/callback.Before sending the user to Google, Compass stores a short-lived authorization intent in browser session storage. That saved intent says whether the user was trying to sign in with Google or connect Google Calendar from inside an existing session.
When Google redirects back to Compass, the callback flow:
/dayas a safe fallbackGoogle authorization is now a deeper web module
The web-side Google authorization behavior now lives under
packages/web/src/auth/google/authorization.That module owns:
The callback page is now a thin loading surface that delegates completion to the module, shows any error, and navigates to the returned path.
Removed stale popup/redirect wrapper code
The old popup-oriented wrapper, misspelled auth config type, and redirect helper folder were removed. Current docs and tests now point at the Google authorization module instead of the deleted redirect helper paths.
Backend now validates the Google redirect URI
The backend derives the expected Google callback URL from the configured frontend URL plus
/auth/google/callback.When exchanging a Google authorization code, the backend rejects requests that do not use that expected callback URL. This keeps the code exchange tied to the Compass instance that initiated the flow.
Calendar connect still syncs local user-created events first
For an existing password-authenticated user connecting Google Calendar, Compass still tries to sync pending local events before redirecting to Google.
After Google returns successfully, Compass connects the Google account, refreshes user metadata, and refetches calendar events so the UI moves into the normal import/sync state.
Demo events are no longer uploaded into real accounts
Seeded demo events are now marked locally in IndexedDB.
That marker is used only in browser storage. When local events are synced into a real account, Compass:
This prevents sample events from becoming real account data.
Docs were updated
The docs now describe the redirect-based Google flow, the new callback URL, and the current module locations.
Updated areas include:
Validation
bun test src/auth/google/authorization/google-authorization.test.ts src/auth/google/authorization/google-authorization.storage.test.ts src/auth/google/authorization/google-authorization.util.test.ts src/auth/google/util/google.auth.util.test.ts src/views/GoogleAuthCallback/GoogleAuthCallback.test.ts src/components/AuthModal/AuthModal.test.tsxfrompackages/web— 61 passedbun run type-checkbunx biome check docs/development/feature-file-map.md packages/web/src/auth/google/authorization packages/web/src/auth/google/hooks/useConnectGoogle/useConnectGoogle.ts packages/web/src/auth/google/util/google.auth.util.ts packages/web/src/auth/google/util/google.auth.util.test.ts packages/web/src/views/GoogleAuthCallback/GoogleAuthCallback.tsx packages/web/src/views/GoogleAuthCallback/GoogleAuthCallback.test.ts packages/web/src/components/AuthModal/AuthModal.tsx packages/web/src/components/AuthModal/AuthModal.test.tsx packages/web/src/__tests__/__mocks__/mock.setup.tsbunx playwright test e2e/oauth/google-auth-callback.spec.ts --project=chromium-desktop— 4 passedgit diff --check