Skip to content

fix(auth): sign in on web via the Firebase popup, not google_sign_in - #24

Merged
danielhstahl merged 1 commit into
masterfrom
feature/fix_tag
Sep 16, 2026
Merged

danielhstahl merged 1 commit into
masterfrom
feature/fix_tag

Conversation

@danielhstahl

Copy link
Copy Markdown
Member

The hosted web build could not sign in at all. ApiRepository obtained the Google credential with GoogleSignIn.instance.authenticate(), and google_sign_in_web refuses that outright -- supportsAuthenticate() is false and authenticate() throws UnimplementedError -- so every tap on the only sign-in button on the only shipping target ended in

sign-in did not complete: UnimplementedError: authenticate is not
supported on the web.

Fix: on the web the popup comes from FirebaseAuth instead (FirebaseAuth.signInWithPopup(GoogleAuthProvider())), which completes the sign-in itself. Native android/iOS keeps the v7 flow it needs -- authenticate() -> idToken -> GoogleAuthProvider.credential -> signInWithCredential -- because signInWithPopup is a web-only capability.

Consequences worth noting:

  • AuthRepository.handleGoogleSignIn now returns the signed-in User rather than an AuthCredential. The two transports reach a user in a different number of steps, and a caller handed a credential would have to run a second sign-in to get a user -- a second popup on the web. The bloc's _signInThenFetchToken no longer makes that call, and the credential conversion moved inside the repository where it is used.
  • The web/native branch is injected (ApiRepository(isWeb:)) so the branch the shipped app takes can be executed under flutter test, where kIsWeb is false. That is why this shipped: every test injected a mocked AuthRepository, so the real web path never ran.
  • FirebaseConfig.googleWebClientId is gone. It existed to feed the google_sign_in web flow; the Firebase popup needs no Google client ID in the app -- the provider is configured on the Firebase project. Nothing else referenced it, and no release script passes GOOGLE_WEB_CLIENT_ID.

Coverage: new test/repositories/api_repository_web_test.dart drives the real ApiRepository against a recording FirebaseAuth -- one popup, with a google.com provider, no follow-up signInWithCredential, and popup failures propagate rather than being swallowed. Verified by mutation: reverting the branch selection fails 5 of those 6 tests.

Failures still surface as ApiNoData carrying the FirebaseAuthException code (popup_blocked_by_browser, popup_closed_by_user, ...), the existing bloc contract.

Issue: workspace-0vt

The hosted web build could not sign in at all. ApiRepository obtained the
Google credential with GoogleSignIn.instance.authenticate(), and
google_sign_in_web refuses that outright -- supportsAuthenticate() is
false and authenticate() throws UnimplementedError -- so every tap on the
only sign-in button on the only shipping target ended in

  sign-in did not complete: UnimplementedError: authenticate is not
  supported on the web.

Fix: on the web the popup comes from FirebaseAuth instead
(FirebaseAuth.signInWithPopup(GoogleAuthProvider())), which completes the
sign-in itself. Native android/iOS keeps the v7 flow it needs --
authenticate() -> idToken -> GoogleAuthProvider.credential ->
signInWithCredential -- because signInWithPopup is a web-only capability.

Consequences worth noting:

- AuthRepository.handleGoogleSignIn now returns the signed-in User rather
  than an AuthCredential. The two transports reach a user in a different
  number of steps, and a caller handed a credential would have to run a
  second sign-in to get a user -- a second popup on the web. The bloc's
  _signInThenFetchToken no longer makes that call, and the credential
  conversion moved inside the repository where it is used.
- The web/native branch is injected (ApiRepository(isWeb:)) so the branch
  the shipped app takes can be executed under `flutter test`, where kIsWeb
  is false. That is why this shipped: every test injected a mocked
  AuthRepository, so the real web path never ran.
- FirebaseConfig.googleWebClientId is gone. It existed to feed the
  google_sign_in web flow; the Firebase popup needs no Google client ID in
  the app -- the provider is configured on the Firebase project. Nothing
  else referenced it, and no release script passes GOOGLE_WEB_CLIENT_ID.

Coverage: new test/repositories/api_repository_web_test.dart drives the
real ApiRepository against a recording FirebaseAuth -- one popup, with a
google.com provider, no follow-up signInWithCredential, and popup failures
propagate rather than being swallowed. Verified by mutation: reverting the
branch selection fails 5 of those 6 tests.

Failures still surface as ApiNoData carrying the FirebaseAuthException code
(popup_blocked_by_browser, popup_closed_by_user, ...), the existing bloc
contract.

Issue: workspace-0vt
@danielhstahl
danielhstahl merged commit 6680374 into master Sep 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant