CompleteRegisterController ​
File: src/Http/Controllers/Auth/CompleteRegisterController.php
Namespace: Unusualify\Modularous\Http\Controllers\Auth
Extends: Auth\Controller
Traits: CreateVerifiedEmailAccount, RespondsWithJsonOrRedirect
Second step in the email-verified registration flow. After the user verifies their email via PreRegisterController, this controller displays the full registration form and creates the user account.
Methods ​
broker() ​
Returns the register broker via Register::broker().
showCompleteRegisterForm(Request $request, $token = null): View|RedirectResponse ​
Displays the complete registration form if the email/token combination is valid.
- Extracts
tokenfrom the route andemailfrom the query string. - Validates the token exists for the email via
Register::broker('register_verified_users')->emailTokenExists(). - Fires the
ModularousUserRegisteringevent. - Builds the form schema from
getFormDraft('complete_register_form'), pre-filling fields from the request (excluding password fields). - Renders the registration view.
If the token is invalid or expired, redirects to the email form with an error.
completeRegister(Request $request): JsonResponse|RedirectResponse ​
Processes the registration form submission:
- Validates all fields via the
CreateVerifiedEmailAccountrules. - Calls
broker()->register()with the submitted credentials. - On success, calls
registerEmail()which:- Creates the
Userrecord with hashed password and verified email. - Creates a
Companyrecord. - Assigns the
client-managerrole. - Fires
ModularousUserRegisteredandVerifiedEmailRegisterevents. - Logs the user in automatically.
- Creates the
- Returns a success or failure response.
sendRegisterResponse(Request $request, $response): JsonResponse|RedirectResponse ​
Returns a success response with translated message and redirect path.
sendRegisterFailedResponse(Request $request, $response): JsonResponse|RedirectResponse ​
Returns a failure response with the error message under the email key.
Validation Rules ​
| Field | Rules |
|---|---|
token | required |
email | required, email |
name | required, no consecutive spaces |
surname | required, no consecutive spaces |
company | required |
password | required, confirmed |
Related ​
- PreRegisterController — first step: sends the email verification link
- RegisterController — direct registration (when email verification is disabled)