AdminAuth::register() registers two routes:
The code is valid for 60 minutes.
verificator selects the channel, email or phone. Enable OTP codes first.
Registration controller
ExtendAdminHelpers\Auth\Controllers\RegisterController and implement its three methods. Read more about validation in Admin Validation.
app/Http/Controllers/Auth/RegisterController.php
$modelis a new instance of the user model. For a user signed in with a social account who finishes the registration, it is the existing user, and$isNewEntryisfalse.getValidatedOtpData()can return anautoAjax()response to stop the registration, e.g. when the account already exists:
$guard in the controller to register into another model.
Registration flow
POST auth/register/otpwith the first step data andverificator. The response contains the OTP data. When the e-mail or phone is already verified, e.g. from a social account, no code is sent andverifiedistrue.POST auth/register/otp-verifywith the final data andtoken. Withouttoken, a new code is sent. A wrong code answers403.
register. Change the message with getSuccessMessage().
After a new user is created, AdminHelpers\Auth\Events\UserRegistered is dispatched.
Checking the code in your own routes
verifyRegistrationOtp($model, $data, $destroyToken) checks the code of the current request. Use it to protect an extra step before the registration is finished, e.g. an upload of a photo:
app/Http/Controllers/Auth/RegisterController.php
false keeps the code valid for the final registration request.