Skip to content

feat(web): add configurable login message - #1668

Merged
brendan-kellam merged 2 commits into
mainfrom
brendan-kellam/login-message-SOU-2272
Sep 17, 2026
Merged

brendan-kellam merged 2 commits into
mainfrom
brendan-kellam/login-message-SOU-2272

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Store the optional message on the organization with an owner-only update action and a 5,000-character limit.
  • Render Markdown formatting and links while excluding raw HTML, images, and unsafe URLs. Messages taller than 120px collapse with an ellipsis and Show more / Show less controls, including in the preview.
  • Tighten login form spacing and place authentication errors below the submit controls with a subtle background.

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/types errors 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 /login and /signup.

The message is stored as Org.loginMessage (new DB column + migration), updated via an owner-only setLoginMessage server action with a 5,000-character limit and whitespace-only values cleared to null. The settings UI uses Write/Preview tabs and reuses the same LoginMessage renderer as the auth pages.

On the auth UI, LoginMessage renders restricted Markdown (no raw HTML/images; links open in a new tab; unsafe javascript: links are not linked). Tall content collapses with Show more/less, including keyboard focus behavior. LoginForm layout 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

  • Persists the optional message on the organization with an owner-only update action and a 5,000-character limit.
  • Renders Markdown formatting and links while blocking raw HTML, images, and unsafe URLs; long messages collapse with Show more/Show less.
  • Moves authentication errors below the sign-in controls and tightens card spacing.

Migration

  • Adds a nullable loginMessage column to the Org table; no data backfill is required.

Written for commit 98a84d0. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Admins can configure a Markdown message for sign-in and sign-up pages.
    • Messages support safe formatting, links, character limits, previews, and expandable display.
    • Added controls in Security Settings to create, edit, preview, and remove the message.
  • Bug Fixes

    • Improved authentication-page spacing and error-message accessibility.
  • Tests

    • Added coverage for message editing, validation, rendering, security, and authentication flows.

@github-actions

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 19e69683-3f8d-45ed-bac7-06b9f8fdd425

📥 Commits

Reviewing files that changed from the base of the PR and between e12bcca and e8f976d.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • packages/db/prisma/migrations/20260917002633_add_org_login_message/migration.sql
  • packages/db/prisma/schema.prisma
  • packages/web/src/__mocks__/prisma.ts
  • packages/web/src/app/(app)/settings/security/actions.test.ts
  • packages/web/src/app/(app)/settings/security/actions.ts
  • packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.test.tsx
  • packages/web/src/app/(app)/settings/security/components/loginMessageSettingsCard.tsx
  • packages/web/src/app/(app)/settings/security/page.tsx
  • packages/web/src/app/login/components/credentialsForm.tsx
  • packages/web/src/app/login/components/loginForm.test.tsx
  • packages/web/src/app/login/components/loginForm.tsx
  • packages/web/src/app/login/page.tsx
  • packages/web/src/app/signup/page.tsx
  • packages/web/src/features/auth/components/loginMessage.test.tsx
  • packages/web/src/features/auth/components/loginMessage.tsx
  • packages/web/src/features/auth/constants.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

Adds 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.

Changes

Organization Login Message

Layer / File(s) Summary
Message storage and owner action
packages/db/prisma/..., packages/web/src/features/auth/constants.ts, packages/web/src/app/(app)/settings/security/actions.ts, packages/web/src/app/(app)/settings/security/actions.test.ts, CHANGELOG.md
Adds nullable Org.loginMessage storage, a 5,000-character limit, an owner-only setLoginMessage action, validation, persistence tests, and a changelog entry.
Security settings management UI
packages/web/src/app/(app)/settings/security/page.tsx, packages/web/src/app/(app)/settings/security/components/*
Adds the login-message settings section and an editor with Write and Preview tabs, character counting, save and clear behavior, error handling, and tests.
Login and signup message rendering
packages/web/src/app/login/page.tsx, packages/web/src/app/signup/page.tsx, packages/web/src/app/login/components/*, packages/web/src/features/auth/components/*
Passes org.loginMessage to LoginForm, renders sanitized Markdown before sign-in options, supports expandable content, and tests login, signup, empty messages, links, and overflow behavior.

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
Loading
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
Loading

Suggested reviewers: msukkari

Merge Risk: ⚪ Minimal · up to e8f97

The owner-managed Markdown login message can be merged without an identified actionable risk.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 14 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a configurable organization login message in the web application.
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.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@cubic-dev-ai cubic-dev-ai 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.

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

Comment thread packages/db/prisma/schema.prisma Resolved
</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>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Suggested change
<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.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Suggested change
.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.`)

Comment thread packages/db/prisma/schema.prisma Resolved

@cubic-dev-ai cubic-dev-ai 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.

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 () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

Comment thread packages/db/prisma/schema.prisma Resolved
@brendan-kellam
brendan-kellam merged commit 93b816a into main Sep 17, 2026
22 checks passed
@brendan-kellam
brendan-kellam deleted the brendan-kellam/login-message-SOU-2272 branch September 17, 2026 20:44
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