Skip to content

chore(repo): fixed dogfooding google login#1269

Open
Brazol wants to merge 2 commits into
mainfrom
fix/dogfooding-login-fixes
Open

chore(repo): fixed dogfooding google login#1269
Brazol wants to merge 2 commits into
mainfrom
fix/dogfooding-login-fixes

Conversation

@Brazol

@Brazol Brazol commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Dogfooding login fixes:

  • Fixed the Google sign-in
  • Changed the default role from admin to user
  • Google sign-in only available in pronto env and to GetStream employees
  • Default login option renamed to "username" instead of "email"

Summary by CodeRabbit

  • New Features

    • Added username-based login alongside the existing sign-in flow.
    • The environment switcher now refreshes the login screen immediately when the environment changes.
  • Bug Fixes

    • Improved login reliability by preventing duplicate sign-in attempts and handling failures more cleanly.
    • Sign-in options now adapt to the platform, reducing issues with web vs. non-web login flows.
  • Chores

    • Updated environment-specific behavior so the Google sign-in option only appears where supported.

@Brazol Brazol requested a review from a team as a code owner July 6, 2026 12:58
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Brazol, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8867841d-d1d1-4633-8b5b-94c7804413d7

📥 Commits

Reviewing files that changed from the base of the PR and between e27c70a and 4f9176c.

📒 Files selected for processing (1)
  • dogfooding/lib/screens/login_screen.dart
📝 Walkthrough

Walkthrough

This PR adds an isPronto environment check, gates GoogleSignIn registration to non-web platforms, and refactors the login screen to support username-based login alongside a Firebase Auth popup flow for web Google sign-in. It also adds an environment-change callback and removes embedded Google/Firebase scripts from index.html.

Changes

Environment-gated login flow

Layer / File(s) Summary
Pronto environment flag and callback wiring
dogfooding/lib/core/model/environment.dart, dogfooding/lib/widgets/environment_switcher.dart
Adds Environment.isPronto getter and an optional onEnvironmentChanged callback invoked after environment selection.
Platform-gated GoogleSignIn registration and auth response handling
dogfooding/lib/di/injector.dart, dogfooding/lib/core/repos/user_auth_repository.dart
GoogleSignIn is registered only on non-web platforms; login() now explicitly branches on Failure/Success instead of using fold.
Login screen Google sign-in refactor
dogfooding/lib/screens/login_screen.dart
Adds aliased firebase_auth import, event-driven Google auth subscription (_initGoogleSignIn, _handleGoogleAuthEvent, _completeGoogleLogin), and web-specific _loginWithGoogleWeb using Firebase Auth popup.
Username login and guest login changes
dogfooding/lib/screens/login_screen.dart
Switches primary input to _usernameController, wires _loginWithUsername, updates labels/icons, and removes hardcoded admin role from guest login.
Login re-entrancy guard, error handling, and Pronto-gated Google button
dogfooding/lib/screens/login_screen.dart
Adds _isLoggingIn guard, _showSnackBar error handling, subscription/controller disposal, environment setState wiring, and shows the Google login button only when Pronto is active.
Removal of embedded Google/Firebase web scripts
dogfooding/web/index.html
Removes Google Sign-In script/meta tag and Firebase SDK script plus inline initialization block.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant LoginScreen
  participant GoogleSignIn
  participant FirebaseAuth
  participant UserAuthRepository

  User->>LoginScreen: Tap Google login (Pronto only)
  alt Web platform
    LoginScreen->>FirebaseAuth: signInWithPopup
    FirebaseAuth-->>LoginScreen: auth result
  else Non-web platform
    LoginScreen->>GoogleSignIn: authenticate()
    GoogleSignIn-->>LoginScreen: authenticationEvents
  end
  LoginScreen->>LoginScreen: _completeGoogleLogin(event)
  LoginScreen->>UserAuthRepository: login()
  UserAuthRepository->>UserAuthRepository: videoClient.connect()
  alt Failure
    UserAuthRepository->>UserAuthRepository: videoClient.disconnect()
    UserAuthRepository-->>LoginScreen: throw error
    LoginScreen->>LoginScreen: _showSnackBar(error)
  else Success
    UserAuthRepository-->>LoginScreen: UserCredentials
    LoginScreen-->>User: Navigate to home
  end
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is only a short bullet list and omits the required Goal, Implementation, UI Changes, Testing, and checklist sections. Expand it to follow the template with Goal, Implementation details, UI Changes, Testing, and the contributor/reviewer checklists.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: dogfooding Google login fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dogfooding-login-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 10.24%. Comparing base (a5eeb44) to head (e27c70a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1269      +/-   ##
==========================================
+ Coverage   10.16%   10.24%   +0.08%     
==========================================
  Files         679      679              
  Lines       49765    49765              
==========================================
+ Hits         5059     5100      +41     
+ Misses      44706    44665      -41     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dogfooding/lib/screens/login_screen.dart`:
- Around line 107-119: The nullable email handling in _completeGoogleLogin is
unsafe because email is force-unwrapped even though both Google sign-in call
sites can pass null. Update _completeGoogleLogin to guard against a missing
email before calling createValidId, and ensure the Google auth flow handles that
failure gracefully instead of relying on email!; also make sure
_handleGoogleAuthEvent and the Firebase/native callers surface an error or skip
login cleanly when the email is absent.
- Around line 71-105: The Google sign-in flow in _loginWithGoogle and
_loginWithGoogleWeb currently only logs failures, so users get no feedback when
authenticate() or signInWithPopup() fails. Update the error handling in both
paths to call _showSnackBar with a clear failure message (alongside or instead
of debugPrint), and make sure the native GoogleSignIn and web FirebaseAuth
branches both surface popup, network, or domain-restriction errors to the user.
- Around line 37-55: Guard the Google Sign-In startup in _initGoogleSignIn()
because locator.getAsync<GoogleSignIn>() can throw and the unawaited call from
initState() would otherwise surface as an unhandled async error. Wrap the async
lookup and subscription setup in try/catch, return early on failure, and check
mounted before assigning _googleAuthSubscription so a late completion after
dispose() does not leave an uncancelled listener.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2d006ff-2ddd-48b4-aa55-71a547b57edd

📥 Commits

Reviewing files that changed from the base of the PR and between a5eeb44 and e27c70a.

📒 Files selected for processing (6)
  • dogfooding/lib/core/model/environment.dart
  • dogfooding/lib/core/repos/user_auth_repository.dart
  • dogfooding/lib/di/injector.dart
  • dogfooding/lib/screens/login_screen.dart
  • dogfooding/lib/widgets/environment_switcher.dart
  • dogfooding/web/index.html
💤 Files with no reviewable changes (1)
  • dogfooding/web/index.html

Comment thread dogfooding/lib/screens/login_screen.dart
Comment thread dogfooding/lib/screens/login_screen.dart
Comment thread dogfooding/lib/screens/login_screen.dart
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