Skip to content

Login with Google — client UI (#4028)#4279

Draft
Celant wants to merge 3 commits into
mainfrom
google-oauth-login
Draft

Login with Google — client UI (#4028)#4279
Celant wants to merge 3 commits into
mainfrom
google-oauth-login

Conversation

@Celant

@Celant Celant commented Jun 14, 2026

Copy link
Copy Markdown
Member

Resolves #4028 (client half — backend is openfrontio/infra#368, which must be deployed first).

Description:

Adds "Login with Google" to the client, alongside the existing Discord login. Companion to the backend PR (openfrontio/infra#368).

  • Auth.tsgoogleLogin() (full-page redirect to /auth/login/google?redirect_uri=…, mirrors discordLogin()).
  • ApiSchemas.tsGoogleUserSchema + optional user.google on UserMeResponseSchema.
  • AccountModal.ts — a "Login with Google" button (Google brand guidelines: white surface, dark text, the multicolor "G" mark) in the login options, and the logged-in view now renders a Google-authenticated user's email (also added google to isLinkedAccount()).
  • en.jsonmain.login_google.
  • resources/images/GoogleLogo.svg — the Google "G" mark.

Draft. Depends on infra#368 being deployed (the button hits the live /auth/login/google).

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

Please put your Discord username so you can be contacted if a bug or regression is found:

jish

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddb2140d-5b9f-428a-ac72-1135a5339604

📥 Commits

Reviewing files that changed from the base of the PR and between c341c43 and 6dd5884.

⛔ Files ignored due to path filters (1)
  • resources/images/GoogleLogo.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • resources/lang/en.json
💤 Files with no reviewable changes (1)
  • resources/lang/en.json

Walkthrough

Adds Google login support to the frontend. A new GoogleUserSchema (with email) is added to the API schema and made optional in UserMeResponseSchema. A googleLogin() function redirects the browser to the backend Google auth endpoint. AccountModal gains a Google login button, a handleGoogleLogin handler, an isLinkedAccount check for me.google, a renderLoggedInAs branch showing the linked Google email, and a matching i18n string.

Changes

Google Login Feature

Layer / File(s) Summary
GoogleUser schema and UserMeResponse extension
src/core/ApiSchemas.ts
Exports GoogleUserSchema with an email field and adds an optional google property to the user object inside UserMeResponseSchema.
googleLogin redirect function
src/client/Auth.ts
Exports googleLogin(), which encodes window.location.href and redirects the browser to /auth/login/google via getApiBase().
AccountModal Google login and linked-account UI
src/client/AccountModal.ts, resources/lang/en.json
Imports googleLogin, extends isLinkedAccount() to include me.google, adds a Google-email display branch in renderLoggedInAs(), inserts a Google login button in the login options UI, and adds handleGoogleLogin(). Adds the main.login_google i18n string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • openfrontio/OpenFrontIO#3986: Modifies src/client/AccountModal.ts including isLinkedAccount() logic and the login/linked-account UI rendering paths, which directly overlap with the Google-account additions in this PR.

Poem

🔵 A button appears, white and bright,
"Login with Google" — what a sight!
The schema grows an email field,
A redirect built, a token sealed.
One more provider joins the game,
The modal glows, never the same. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding Google login UI to the client, which aligns with all modified files and the PR objective.
Description check ✅ Passed The description thoroughly explains the changes across all modified files, references the related issue and backend PR, and addresses the author's work in progress status.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/core/ApiSchemas.ts (1)

69-69: 💤 Low value

Consider using z.email() for email validation.

Zod 4 provides a standalone z.email() schema for validating email format. While the current z.string() matches the pattern used in DiscordUserSchema, using z.email() would add client-side validation and make the schema more explicit.

✨ Optional enhancement
 export const GoogleUserSchema = z.object({
-  email: z.string(),
+  email: z.email(),
 });
🤖 Prompt for 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.

In `@src/core/ApiSchemas.ts` at line 69, Replace the `email: z.string()` field
definition with `z.email()` to leverage Zod 4's built-in email validation
schema. This change adds explicit email format validation at the schema level,
making the validation requirements clearer and improving client-side validation
capabilities.
🤖 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 `@src/core/ApiSchemas.ts`:
- Around line 68-71: The GoogleUserSchema and its corresponding GoogleUser type
inference are missing test coverage. Create test cases that validate the schema
correctly enforces the email field as a required string and verify that the type
inference for GoogleUser is properly derived from GoogleUserSchema. Include
tests for both valid inputs (valid email strings) and invalid inputs (empty
strings, non-string values) to ensure the schema validation works as expected.

---

Nitpick comments:
In `@src/core/ApiSchemas.ts`:
- Line 69: Replace the `email: z.string()` field definition with `z.email()` to
leverage Zod 4's built-in email validation schema. This change adds explicit
email format validation at the schema level, making the validation requirements
clearer and improving client-side validation capabilities.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a5bab8b-f1f1-4a90-bf42-0261bd6c9307

📥 Commits

Reviewing files that changed from the base of the PR and between bb5e7dc and 738f676.

📒 Files selected for processing (4)
  • resources/lang/en.json
  • src/client/AccountModal.ts
  • src/client/Auth.ts
  • src/core/ApiSchemas.ts

Comment thread src/core/ApiSchemas.ts
Comment on lines +68 to +71
export const GoogleUserSchema = z.object({
email: z.string(),
});
export type GoogleUser = z.infer<typeof GoogleUserSchema>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Missing tests for src/core/ changes.

According to coding guidelines, all changes to src/core/ must include tests. This new schema should have test coverage to validate the email field and type inference.

🤖 Prompt for 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.

In `@src/core/ApiSchemas.ts` around lines 68 - 71, The GoogleUserSchema and its
corresponding GoogleUser type inference are missing test coverage. Create test
cases that validate the schema correctly enforces the email field as a required
string and verify that the type inference for GoogleUser is properly derived
from GoogleUserSchema. Include tests for both valid inputs (valid email strings)
and invalid inputs (empty strings, non-string values) to ensure the schema
validation works as expected.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

[Feature] OAuth / Google login — milestone before required sign-in rollout

1 participant