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

Extend AdminHelpers\Auth\Controllers\RegisterController and implement its three methods. Read more about validation in Admin Validation.
app/Http/Controllers/Auth/RegisterController.php
  • $model is 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 $isNewEntry is false.
  • getValidatedOtpData() can return an autoAjax() response to stop the registration, e.g. when the account already exists:
The model is chosen by the default guard. Set $guard in the controller to register into another model.

Registration flow

  1. POST auth/register/otp with the first step data and verificator. 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 and verified is true.
  2. POST auth/register/otp-verify with the final data and token. Without token, a new code is sent. A wrong code answers 403.
The success response is the same as the login response, with a token named 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.