Skip to content

feat: disable public signup toggle and react sdk prop - #337

Merged
yash-pouranik merged 4 commits into
mainfrom
feat/disable-public-signup
Jun 23, 2026
Merged

feat: disable public signup toggle and react sdk prop#337
yash-pouranik merged 4 commits into
mainfrom
feat/disable-public-signup

Conversation

@yash-pouranik

@yash-pouranik yash-pouranik commented Jun 23, 2026

Copy link
Copy Markdown
Member
  1. Disable Public Signup Toggle
    Backend: Added the allowPublicSignup field to the project schema. The /api/projects/:projectId/auth/public-signup endpoint now allows toggling this setting.
    Enforcement: Updated the signup and OAuth callback methods in userAuth.controller.js to immediately block new users with a 403 error if allowPublicSignup is false. Existing users can still log in fine.
    Dashboard UI: Added a beautiful toggle under the "Settings" section on the Authentication page (Auth.jsx).

  2. React SDK hideSignup Prop
    Added an optional hideSignup?: boolean prop to inside @urbackend/react.
    When set to true, the "Sign Up" tab on the authentication widget is completely hidden, and it defaults to the signin mode.

Summary by CodeRabbit

  • New Features
    • Project administrators can now enable or disable public signups from project settings via a new toggle control
    • New user registrations via email and social authentication are blocked when public signups are disabled for the project
    • Authentication SDK now includes an option to hide the signup interface in authentication flows

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@yash-pouranik, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 35 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

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

🚦 How do rate limits work?

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

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b3cc66ec-a1df-48b9-bb35-9a0eac83d49d

📥 Commits

Reviewing files that changed from the base of the PR and between 3f5bd86 and 23e4122.

📒 Files selected for processing (8)
  • README.md
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/public-api/src/controllers/userAuth.controller.js
  • apps/web-dashboard/src/pages/Auth.jsx
  • mintlify/docs/guides/authentication.mdx
  • mintlify/docs/react-sdk/ur-auth.mdx
  • sdks/urbackend-react/README.md
  • sdks/urbackend-react/src/components/UrAuth.tsx
📝 Walkthrough

Walkthrough

Adds an allowPublicSignup boolean flag to the Project model (default true). A new PATCH endpoint in the dashboard API toggles the flag with cache invalidation. The public API enforces the flag by returning 403 errors in both email/password and social signup flows. The dashboard UI exposes a toggle switch in the Settings section, and the React SDK gains a hideSignup prop that suppresses the auth-mode switcher.

Changes

Public Signup Toggle

Layer / File(s) Summary
Project schema: allowPublicSignup field
packages/common/src/models/Project.js
Adds allowPublicSignup: { type: Boolean, default: true } to the Project Mongoose schema.
Dashboard API: toggle endpoint and route
apps/dashboard-api/src/controllers/project.controller.js, apps/dashboard-api/src/routes/projects.js, apps/dashboard-api/src/__tests__/routes.projects.storage.test.js
Adds togglePublicSignup controller that updates allowPublicSignup and invalidates project/API-key caches; wires it to a new PATCH route /:projectId/auth/public-signup behind admin + email-verified guards; stubs the method in the Jest route mock.
Public API signup enforcement
apps/public-api/src/controllers/userAuth.controller.js
Adds early 403 AppError guards in both the email/password signup handler and the findOrCreateSocialUser path when project.allowPublicSignup === false.
Dashboard UI: Allow Public Signups toggle
apps/web-dashboard/src/pages/Auth.jsx
Adds handleTogglePublicSignup handler that PATCHes the new endpoint and updates project state with toasts; inserts a Settings card with a checkbox switch bound to project?.allowPublicSignup.
React SDK: hideSignup prop
sdks/urbackend-react/src/components/UrAuth.tsx
Adds optional hideSignup?: boolean to UrAuthProps and changes showSwitcher to hasPasswordAuth && !hideSignup, hiding the sign-in/sign-up switcher when the prop is set.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

feature, backend, frontend, type:security

Suggested reviewers

  • Nitin-kumar-yadav1307

Poem

🐰 A bunny hops in to declare:
No more open doors if you don't dare!
allowPublicSignup guards the gate,
A toggle switch decides each user's fate.
With 403s now blocking the queue,
Only invited guests hop through! 🚪✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the two main features: a public signup toggle and a React SDK prop for hiding signup.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/disable-public-signup

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.

@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: 6

🤖 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 `@apps/dashboard-api/src/controllers/project.controller.js`:
- Around line 2565-2583: The response in this handler does not follow the
standard API envelope format and exposes internal error details. Refactor the
success response to use the standardized envelope with success: true, a data
object containing the project information and allowPublicSignup flag, and an
appropriate message field. For the error handling in the catch block, replace
the direct res.status(500).json({ error: err.message }) call with proper
AppError class usage that handles errors securely without exposing raw error
messages to clients, following the controller's contract of returning { success:
bool, data: {}, message: "" } format.
- Around line 2559-2568: The code currently uses `!!enable` to coerce the
request body value to a boolean, which silently treats invalid or missing values
as false and can unintentionally disable public signup. Instead of using the
coercion operator, explicitly validate that the enable parameter from req.body
is a boolean type. If it is not a boolean, return a 400 status code with an
appropriate error message. Only assign the validated boolean value directly to
project.allowPublicSignup without any coercion.

In `@apps/public-api/src/controllers/userAuth.controller.js`:
- Around line 620-624: Replace the raw Error object being thrown in the signup
gate check (the if block where `project.allowPublicSignup === false`) with an
AppError instance instead, passing the same "Public signup is disabled for this
project. Only existing users can log in." message and 403 status code. This will
ensure consistency with the controller's error handling requirements and the
established AppError usage pattern throughout the file, so that the response
format returned will conform to the required `{ success: bool, data: {},
message: "" }` structure.

In `@apps/web-dashboard/src/pages/Auth.jsx`:
- Around line 151-159: The handleTogglePublicSignup function is missing
protection against race conditions and unauthorized access. Add an in-flight
state variable to track pending requests and guard the function to prevent
execution if a request is already in progress or if the user is a viewer. In the
function body, check both the in-flight state and user role (isViewer) before
making the API call, setting the loading state before the request and clearing
it in both success and error handlers. Also disable the public signup toggle
control in the UI when either the in-flight state is true or the user is a
viewer. Apply this same pattern to the similar function at lines 377-382.

In `@sdks/urbackend-react/src/components/UrAuth.tsx`:
- Around line 199-200: The variable `showSwitcher` is declared twice using const
in the same scope in the UrAuth component, causing a redeclaration error. Remove
the duplicate `showSwitcher` declaration (the second one at line 211) and keep
only the first declaration at line 200 which assigns the value based on
`hasPasswordAuth && !hideSignup`. This will resolve the block-scoped
redeclaration error and allow the code to compile successfully.
- Around line 199-200: The hideSignup prop is only being enforced for the top
switcher via the showSwitcher variable, but the footer button that toggles mode
to signup is not respecting this prop. Apply the same hideSignup condition to
the footer button toggle (where it toggles mode to signup in the footer area) so
that when hideSignup is true, users cannot access signup through either the top
switcher or the footer button, ensuring the prop is fully enforced throughout
the component.
🪄 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: 0dd73f2a-9d05-4a6d-8299-8481f893dac6

📥 Commits

Reviewing files that changed from the base of the PR and between 22b9f25 and 3f5bd86.

📒 Files selected for processing (7)
  • apps/dashboard-api/src/__tests__/routes.projects.storage.test.js
  • apps/dashboard-api/src/controllers/project.controller.js
  • apps/dashboard-api/src/routes/projects.js
  • apps/public-api/src/controllers/userAuth.controller.js
  • apps/web-dashboard/src/pages/Auth.jsx
  • packages/common/src/models/Project.js
  • sdks/urbackend-react/src/components/UrAuth.tsx

Comment thread apps/dashboard-api/src/controllers/project.controller.js
Comment thread apps/dashboard-api/src/controllers/project.controller.js Outdated
Comment thread apps/public-api/src/controllers/userAuth.controller.js
Comment thread apps/web-dashboard/src/pages/Auth.jsx
Comment thread sdks/urbackend-react/src/components/UrAuth.tsx
@yash-pouranik

Copy link
Copy Markdown
Member Author

ok to merge?
@coderabbitai?

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check PR status, reviews, and open comments
gh pr view 337 --repo geturbackend/urBackend --json state,reviewDecision,mergeable,statusCheckRollup,reviews,comments

# Check review comments (inline code comments)
gh api repos/geturbackend/urBackend/pulls/337/comments --jq '[.[] | {id, user: .user.login, body: .body, resolved: .resolved}]' 2>/dev/null | head -200

# Check open review threads
gh api repos/geturbackend/urBackend/pulls/337/reviews --jq '[.[] | {id, user: .user.login, state, body}]' 2>/dev/null

Length of output: 40726



@yash-pouranik Yes, this looks good to merge! Here's the summary:

  • All CI checks pass (frontend-lint, dashboard-api-tests, public-api-tests, sdk-tests, python-sdk-tests, CodeQL)
  • All 6 review comments addressed in commit 171e279 — boolean validation for enable, standardized response envelope + AppError usage, in-flight race condition guard on the UI toggle, duplicate showSwitcher declaration fix, and hideSignup fully enforced on the footer button
  • ⚠️ Docstring coverage warning (0% vs 80% threshold) — this appears to be a pre-existing repo-wide issue, not introduced by this PR

The PR is mergeable. 🐰

@yash-pouranik
yash-pouranik temporarily deployed to feat/disable-public-signup - urBackend-frankfrut PR #337 June 23, 2026 21:43 — with Render Destroyed
@mintlify

mintlify Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
urbackend 🟢 Ready View Preview Jun 23, 2026, 9:44 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@yash-pouranik
yash-pouranik merged commit 9265584 into main Jun 23, 2026
9 checks passed
@yash-pouranik
yash-pouranik deleted the feat/disable-public-signup branch June 23, 2026 21:56
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.

2 participants