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
- Web or mobile user registers a new account by calling the route
Route::post('register', 'AuthController@register')
and the controller register method is this
public 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
}
- User get an email with a
Verify Email Address
button
Now 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