I was following a post on medium on how to do API email verification in Laravel 5.8 here https://medium.com/@pran.81/how-to-implement-laravels-must-verify-email-feature-in-the-api-registration-b531608ecb99
I tested it and it works perfectly but I was wondering how it would work when a web or mobile application consumes the API. Here are my thoughts
Route::post('register', 'AuthController@register')
and the controller register method is thispublic function register(Request $request)
{
// validate inputs
// store new user & send verify email notification to user
$user = User::create([
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'username' => $request->username,
'password' => bcrypt($request->password)
]);
$user->sendApiEmailVerificationNotification();
// assign access token to newly registered user
// return access token & user data
}
Verify Email Address
buttonNow what should happen next? Should the user be redirected to the web app login page? If yes, how do I customise the redirect url? At the moment when I click on the verify email address button, a browser opens up and I get all the response on the browser page like this
Once the user clicks on Verify they are redirected to the path mentioned in
App\Http\Controllers\Auth\VerificationController
Now if you want to change the redirect after verification you can change the below line of code with your route in VerificationController
/** * Where to redirect users after verification. * * @var string */ protected $redirectTo = '/home';