Skip to content

Extract RegistrationService; consolidate registration across four controllers - #46

Merged
sambhav-aggarwal merged 1 commit into
mainfrom
feature/registration_cleanup
Jul 2, 2026
Merged

Extract RegistrationService; consolidate registration across four controllers#46
sambhav-aggarwal merged 1 commit into
mainfrom
feature/registration_cleanup

Conversation

@sambhav-aggarwal

Copy link
Copy Markdown
Member

What

Phase-1 cleanup from the roadmap: the registration logic that had drifted into four near-duplicates (web registerStore, API register, and both OAuth register() copies) now lives in one RegistrationService:

  • shared validation rules (web + API)
  • user creation, invitation acceptance (throws InvalidInvitationException — each controller shapes it into its own 400 / back()->withErrors), federated-domain team-creation rules, OAuth registration (provider-verified email, unique username generation), transaction ownership, and the Registered event

Controllers shrink to request/response shaping (net −93 lines). This is also deliberate groundwork: the two upcoming registration-time integrations — email-reputation checks and RFC-001's self-registration routing — now have a single place to plug in instead of four.

Also

  • Domain::isVerifiedForEmail() replaces four identical private isDomainVerified() methods plus a fifth inline variant in loginPassword
  • Removed MembershipService — verified unused (never injected or referenced; 23 dead lines)

Behaviour

Preserved — the full suite passes unchanged (1004 tests), which is the point: the existing registration/OAuth/invitation feature tests all exercise the consolidated path. One error-path message differs: API OAuth registration failure surfaces as the generic OAuth authentication failed. 500 rather than Unable to register user. (the service throws instead of returning null). Pint and PHPStan clean.

…trollers

Web registerStore, API register, and both OAuth register() copies had
drifted duplicates of the same logic. RegistrationService now owns:

- validation rules (shared by web + API)
- user creation, invitation acceptance (InvalidInvitationException for
  controllers to shape into 400/back()->withErrors), federated-domain
  team-creation rules, OAuth registration (verified email, generated
  username), the transaction, and the Registered event

Controllers shrink to request/response shaping. Future registration
hooks (email reputation checks, RFC-001 self-registration routing)
now have a single integration point.

Also:
- Domain::isVerifiedForEmail() replaces four identical private
  isDomainVerified() methods plus one inline variant
- Removed MembershipService (verified unused: never injected or
  referenced anywhere)

Behaviour preserved: full suite green unchanged (1004 tests). One
error-path message changes: API OAuth registration failure now surfaces
as the generic 'OAuth authentication failed.' 500 instead of 'Unable
to register user.' (the service throws instead of returning null).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Caution

This repository is currently using the Sentry GitHub App to receive Codecov PR comments. This integration will be deprecated on July 8, 2026. Please install the Codecov GitHub App to continue receiving coverage reports on your pull requests.
❌ Patch coverage is 80.20833% with 19 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/Services/RegistrationService.php | 88.57% | 8 Missing ⚠️ |
| src/Http/Controllers/Auth/UserAuthController.php | 12.50% | 7 Missing ⚠️ |
| src/Http/Controllers/Auth/OAuthApiController.php | 0.00% | 2 Missing ⚠️ |
| src/Http/Controllers/Auth/OAuthController.php | 50.00% | 2 Missing ⚠️ |

📢 Thoughts on this report? Let us know!

@sambhav-aggarwal
sambhav-aggarwal merged commit 5c27c05 into main Jul 2, 2026
4 checks passed
@sambhav-aggarwal
sambhav-aggarwal deleted the feature/registration_cleanup branch July 2, 2026 11:06
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