Skip to content

feat(auth): add registration toggle and handle registration logic in … - #53

Merged
roble merged 1 commit into
mainfrom
dev-improvements
Aug 30, 2026
Merged

roble merged 1 commit into
mainfrom
dev-improvements

Conversation

@roble

@roble roble commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

This pull request introduces a comprehensive "registration enabled" feature toggle for user sign-up, affecting both standard and social authentication flows. The toggle allows administrators to control whether new users can register via the sign-up page or social login, with appropriate UI, backend, and settings changes. It also includes localization, middleware enforcement, exception handling, and thorough test coverage.

Registration Toggle Feature

  • Added a new registration_enabled setting to AuthSettings, with a migration to default it to true, and exposed it to the frontend via Inertia. [1] [2] [3]
  • Implemented EnsureRegistrationEnabled middleware to block register routes with a 404 when registration is disabled, and applied it in routes/web.php. [1] [2] [3]
  • Updated the authentication UI (React and Vue login pages) to only show the "Sign up" link if registration is enabled. [1] [2] [3] [4] [5]
  • Added a new section to the Filament admin settings page to allow toggling registration, with helper text and test ID.

Social Authentication Integration

  • Modified SocialiteService to throw a specific exception if registration is disabled and a new user tries to sign in with a social provider; updated controller to handle this gracefully. [1] [2] [3]
  • Updated documentation and exception lists to clarify the new registration-disabled behavior for social logins. [1] [2]

Localization and Messaging

  • Added English and Brazilian Portuguese translations for registration toggle UI and the new "registration disabled" error. [1] [2] [3] [4]

Testing

  • Added and updated feature tests to verify that registration and social sign-up are blocked when disabled, while existing users can still log in. [1] [2] [3]

Summary by CodeRabbit

  • New Features

    • Added an authentication setting to enable or disable visitor registration.
    • Registration controls are available in the authentication settings.
    • Social sign-in cannot create new accounts when registration is disabled, while existing users can still sign in.
    • Added English and Brazilian Portuguese translations.
  • Bug Fixes

    • Registration links are hidden when registration is disabled.
    • Registration pages return a not-found response when disabled.
    • Social sign-in now shows an error and returns to login when account creation is blocked.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 678eb9fd-d196-453b-9932-a537213ce6d6

📥 Commits

Reviewing files that changed from the base of the PR and between 2df0e50 and 544b3c4.

📒 Files selected for processing (20)
  • CLAUDE.md
  • database/settings/2026_08_30_120000_add_registration_enabled_to_auth_settings.php
  • lang/en/auth.php
  • lang/en/socialite.php
  • lang/pt_BR/auth.php
  • lang/pt_BR/socialite.php
  • resources/js/react/pages/Login.tsx
  • resources/js/types/page-props.d.ts
  • resources/js/vue/pages/Login.vue
  • routes/web.php
  • src/Exceptions/SocialiteException.php
  • src/Filament/Pages/AuthenticationSettings.php
  • src/Http/Controllers/SocialiteController.php
  • src/Http/Middleware/EnsureRegistrationEnabled.php
  • src/Providers/AuthServiceProvider.php
  • src/Services/SocialiteService.php
  • src/Settings/AuthSettings.php
  • tests/Feature/AuthSettingsTest.php
  • tests/Feature/RegisterTest.php
  • tests/Feature/SocialiteCallbackTest.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds a persisted registration_enabled setting. Disabled registration returns 404 for register routes, blocks new social accounts, preserves existing-user login, and hides signup links in React and Vue login pages.

Changes

Registration Control

Layer / File(s) Summary
Registration setting and configuration
database/settings/*, src/Settings/AuthSettings.php, src/Filament/Pages/AuthenticationSettings.php, lang/*/auth.php, tests/Feature/AuthSettingsTest.php, CLAUDE.md
Adds the registration_enabled setting with a default of true, exposes it in authentication settings, adds English and Portuguese translations, and verifies the default.
Registration route and social-login enforcement
src/Http/Middleware/EnsureRegistrationEnabled.php, routes/web.php, src/Exceptions/SocialiteException.php, src/Services/SocialiteService.php, src/Http/Controllers/SocialiteController.php, lang/*/socialite.php, tests/Feature/RegisterTest.php, tests/Feature/SocialiteCallbackTest.php, CLAUDE.md
Returns 404 for disabled registration routes, blocks new social accounts, preserves existing-user social login, and redirects rejected callbacks to login with an error toast.
Shared authentication state and login visibility
src/Providers/AuthServiceProvider.php, resources/js/types/page-props.d.ts, resources/js/react/pages/Login.tsx, resources/js/vue/pages/Login.vue
Shares registration_enabled through Inertia and hides signup links when registration is disabled.

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

Merge Risk: ⚪ Minimal · up to 544b3

The toggle consistently controls new password and social account creation while preserving authentication for existing users, and no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Visitor
  participant RegistrationMiddleware
  participant SocialiteController
  participant SocialiteService
  Visitor->>RegistrationMiddleware: Request registration route
  RegistrationMiddleware-->>Visitor: Return 404 when registration is disabled
  Visitor->>SocialiteController: Submit social callback
  SocialiteController->>SocialiteService: handleCallback(provider)
  SocialiteService-->>SocialiteController: Reject new account
  SocialiteController-->>Visitor: Show error toast and redirect to login
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 18 files. (2 skipped: … 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 identifies the main change: adding a registration toggle and handling registration logic. The trailing ellipsis does not prevent understanding the primary purpose.
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 9.52% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 18 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-improvements

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.

@roble
roble merged commit d924d45 into main Aug 30, 2026
8 of 10 checks passed
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