Level 1
when i click complete registration button it just redirect to a blank page with only a json response
status: "success"
data: [ ]
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
why is it returns like this where i click complete registration? i checked the route and the code but it seems it didn't go through the controller. can anyone help me im stuck
public function register(Request $request)
{
if(DB::table('users')->where('student_no', '=', $request['student_no'])->exists()){
$user = User::where('student_no', '=', $request['student_no'])->first();
return back()->withErrors(['message' => 'student number is already taken ']);
}else {
//Validate the incoming request using the already included validator method
$this->validator($request->all())->validate();
// Initialise the 2FA class
$google2fa = app('pragmarx.google2fa');
// Save the registration data in an array
$registration_data = $request->all();
// Add the secret key to the registration data
$registration_data["google2fa_secret"] = $google2fa->generateSecretKey();
// Save the registration data to the user session for just the next request
$request->session()->flash('registration_data', $registration_data);
// Generate the QR image. This is the image the user will scan with their app
// to set up two factor authentication
$QR_Image = $google2fa->getQRCodeInline(
config('app.name'),
$registration_data['email'],
$registration_data['google2fa_secret']
);
// Pass the QR barcode image to our view
return view('google2fa.register', ['QR_Image' => $QR_Image, 'secret' => $registration_data['google2fa_secret']]);
}
}
public function completeRegistration(Request $request)
{
// add the session data back to the request input
$request->merge(session('registration_data'));
// Call the default laravel authentication
return $this->registration($request);
}
Route
Route::get('register', 'RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'RegisterController@register')->name('register.post');
Route::get('/complete-registration', 'RegisterController@completeRegistration')->name('complete-registration');
Please or to participate in this conversation.