Repository navigation
feat(web): add configurable login message - #1668
Conversation
This comment has been minimized.
This comment has been minimized.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. WalkthroughAdds an optional organization Markdown message. Owners can edit it in security settings. The message is validated, stored, and displayed with sanitized, expandable content on sign-in and sign-up pages. ChangesOrganization Login Message
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Owner
participant LoginMessageSettingsCard
participant setLoginMessage
participant Org
Owner->>LoginMessageSettingsCard: Edit and save Markdown
LoginMessageSettingsCard->>setLoginMessage: Submit trimmed message or null
setLoginMessage->>Org: Persist loginMessage
Org-->>setLoginMessage: Return persistence result
setLoginMessage-->>LoginMessageSettingsCard: Return success or error
sequenceDiagram
participant LoginPage
participant SignupPage
participant LoginForm
participant LoginMessage
LoginPage->>LoginForm: Pass org.loginMessage
SignupPage->>LoginForm: Pass org.loginMessage
LoginForm->>LoginMessage: Render message
LoginMessage-->>LoginForm: Show sanitized expandable Markdown
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The owner-managed Markdown login message can be merged without an identified actionable risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 14 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
2 issues found across 17 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.tsx">
<violation number="1" location="packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.tsx:74">
P3: When an admin uses a non-English browser, this locale-dependent count can differ from the server-rendered text and trigger a hydration mismatch. Use a fixed locale for both values, consistent with the app's English document language.</violation>
</file>
<file name="packages/web/src/app/(app)/settings/security/actions.ts">
<violation number="1" location="packages/web/src/app/(app)/settings/security/actions.ts:18">
P3: The validation error hard-codes `5,000` while the limit comes from `LOGIN_MESSAGE_MAX_LENGTH`. Build the message from the constant so future limit changes remain accurate.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| </Tabs> | ||
| <div className="mt-3 flex items-start justify-between gap-4 text-xs text-muted-foreground"> | ||
| <p id={`${id}-hint`}>Use Markdown for formatting and links. Leave empty to hide the message.</p> | ||
| <span id={`${id}-count`} className="shrink-0">{draft.length.toLocaleString()} / {LOGIN_MESSAGE_MAX_LENGTH.toLocaleString()}</span> |
There was a problem hiding this comment.
P3: When an admin uses a non-English browser, this locale-dependent count can differ from the server-rendered text and trigger a hydration mismatch. Use a fixed locale for both values, consistent with the app's English document language.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.tsx, line 74:
<comment>When an admin uses a non-English browser, this locale-dependent count can differ from the server-rendered text and trigger a hydration mismatch. Use a fixed locale for both values, consistent with the app's English document language.</comment>
<file context>
@@ -0,0 +1,84 @@
+ </Tabs>
+ <div className="mt-3 flex items-start justify-between gap-4 text-xs text-muted-foreground">
+ <p id={`${id}-hint`}>Use Markdown for formatting and links. Leave empty to hide the message.</p>
+ <span id={`${id}-count`} className="shrink-0">{draft.length.toLocaleString()} / {LOGIN_MESSAGE_MAX_LENGTH.toLocaleString()}</span>
+ </div>
+ {error && <p role="alert" className="mt-3 text-sm text-destructive">{error}</p>}
</file context>
| <span id={`${id}-count`} className="shrink-0">{draft.length.toLocaleString()} / {LOGIN_MESSAGE_MAX_LENGTH.toLocaleString()}</span> | |
| <span id={`${id}-count`} className="shrink-0">{draft.length.toLocaleString("en-US")} / {LOGIN_MESSAGE_MAX_LENGTH.toLocaleString("en-US")}</span> |
| import { LOGIN_MESSAGE_MAX_LENGTH } from "@/features/auth/constants"; | ||
|
|
||
| const loginMessageSchema = z.string() | ||
| .max(LOGIN_MESSAGE_MAX_LENGTH, "Login message must be 5,000 characters or fewer.") |
There was a problem hiding this comment.
P3: The validation error hard-codes 5,000 while the limit comes from LOGIN_MESSAGE_MAX_LENGTH. Build the message from the constant so future limit changes remain accurate.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/web/src/app/(app)/settings/security/actions.ts, line 18:
<comment>The validation error hard-codes `5,000` while the limit comes from `LOGIN_MESSAGE_MAX_LENGTH`. Build the message from the constant so future limit changes remain accurate.</comment>
<file context>
@@ -4,13 +4,38 @@ import { getProviders } from "@/auth";
+import { LOGIN_MESSAGE_MAX_LENGTH } from "@/features/auth/constants";
+
+const loginMessageSchema = z.string()
+ .max(LOGIN_MESSAGE_MAX_LENGTH, "Login message must be 5,000 characters or fewer.")
+ .nullable()
+ .transform(message => message?.trim() ? message : null);
</file context>
| .max(LOGIN_MESSAGE_MAX_LENGTH, "Login message must be 5,000 characters or fewer.") | |
| .max(LOGIN_MESSAGE_MAX_LENGTH, `Login message must be ${LOGIN_MESSAGE_MAX_LENGTH.toLocaleString()} characters or fewer.`) |
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.test.tsx">
<violation number="1" location="packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.test.tsx:18">
P2: The character-limit and failure paths the PR explicitly highlights are untested. The component disables Save once `draft.length > LOGIN_MESSAGE_MAX_LENGTH` and renders `'Failed to save the login message. Please try again.'` when `setLoginMessage` rejects, but no test exercises either; only the service-error `{ errorCode, ... }` path is covered. Add a test that verifies the Save button stays disabled above 5,000 characters (count is user-visible) and one where the action rejects (mocks.save.mockRejectedValueOnce) asserting the catch branch's alert text.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }); | ||
| afterEach(cleanup); | ||
|
|
||
| test('saves Markdown only after editing and marks a successful save as unchanged', async () => { |
There was a problem hiding this comment.
P2: The character-limit and failure paths the PR explicitly highlights are untested. The component disables Save once draft.length > LOGIN_MESSAGE_MAX_LENGTH and renders 'Failed to save the login message. Please try again.' when setLoginMessage rejects, but no test exercises either; only the service-error { errorCode, ... } path is covered. Add a test that verifies the Save button stays disabled above 5,000 characters (count is user-visible) and one where the action rejects (mocks.save.mockRejectedValueOnce) asserting the catch branch's alert text.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.test.tsx, line 18:
<comment>The character-limit and failure paths the PR explicitly highlights are untested. The component disables Save once `draft.length > LOGIN_MESSAGE_MAX_LENGTH` and renders `'Failed to save the login message. Please try again.'` when `setLoginMessage` rejects, but no test exercises either; only the service-error `{ errorCode, ... }` path is covered. Add a test that verifies the Save button stays disabled above 5,000 characters (count is user-visible) and one where the action rejects (mocks.save.mockRejectedValueOnce) asserting the catch branch's alert text.</comment>
<file context>
@@ -0,0 +1,58 @@
+});
+afterEach(cleanup);
+
+test('saves Markdown only after editing and marks a successful save as unchanged', async () => {
+ render(<LoginMessageSettingsCard loginMessage="Old message" />);
+ const save = screen.getByRole('button', { name: 'Save changes' }) as HTMLButtonElement;
</file context>
Fixes SOU-2272
Admins can now publish access instructions and registration links above the sign-in and sign-up forms. Owners edit a Markdown message under Settings → Security, below SCIM, with Write and Preview tabs; clearing it hides the message.
Validation: 32 focused tests pass, covering authorization, validation, persistence, editing, Markdown rendering, and expansion behavior. ESLint passes for all changed TypeScript files. Type checking reports six existing generated
.next/typeserrors in unrelated settings routes. The migration was applied successfully to the local development database.Note
Medium Risk
Introduces admin-editable content on unauthenticated login/signup pages and a schema migration; rendering is constrained but any misconfiguration could still mislead users before authentication.
Overview
Adds an optional org-level login message that owners configure under Settings → Security and that appears above sign-in options on
/loginand/signup.The message is stored as
Org.loginMessage(new DB column + migration), updated via an owner-onlysetLoginMessageserver action with a 5,000-character limit and whitespace-only values cleared tonull. The settings UI uses Write/Preview tabs and reuses the sameLoginMessagerenderer as the auth pages.On the auth UI,
LoginMessagerenders restricted Markdown (no raw HTML/images; links open in a new tab; unsafejavascript:links are not linked). Tall content collapses with Show more/less, including keyboard focus behavior.LoginFormlayout is adjusted so the message sits above auth methods and auth errors appear below the selector.Reviewed by Cursor Bugbot for commit e8f976d. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes SOU-2272 by letting organizations show a Markdown message above the sign-in and sign-up forms. Owners set or clear it under Settings → Security; an empty message hides it.
New Features
Migration
loginMessagecolumn to theOrgtable; no data backfill is required.Written for commit 98a84d0. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests