我创建了一个中间件来检查登录身份验证,但当我重定向重定向时,我收到了这个错误。
中间件/TwoFA.php
public function handle($request, Closure $next)
{
$response = $next($request);
if(Auth::check()){
if(auth()->user()->is_verified == true){
return $response;
}else {
return redirect('/verifyOTP');
}
}
return $response;
}
kernel.php
'web' => [
AppHttpMiddlewareTwoFA::class,
],
web.php
Route::get('verifyOTP', 'VerifyOTPController@showVerifyPage')->name('verify');
Route::post('verifyOTP', 'VerifyOTPController@verify');
Route::group(['middleware'=>'TwoFA'], function (){
Route::get('/home', 'HomeController@doashboard')->name('doashboard');
});
添加
use AppHttpMiddlewareTwoFA;
到web.php
并更改
Route::group(['middleware' => TwoFA::class], function () {
Route::get('/home', 'HomeController@doashboard')->name('doashboard');
});