В моем приложении laravel 5.7.3 я использую расширение https://github.com/jrean/laravel-user-verification и с использованием промежуточного программного обеспечения генерирую ошибку UserNotVerifiedException, когда вход в систему не проверяется, но с исключением я хочу выйти из системы и перенаправить на страницу / login и читатьhttps://laravel.com/docs/master/errors#the-exception-handler Документ в файле app / Exceptions / Handler.php Я делаю:
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Auth;
use App\Exceptions\UserNotVerifiedException;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Foundation\Auth\RegistersUsers;
use Jrean\UserVerification\Traits\VerifiesUsers; // Do I need to add these declarations here ?
use Jrean\UserVerification\Facades\UserVerification;
class Handler extends ExceptionHandler
{
use RegistersUsers;
use VerifiesUsers;
protected $dontReport = [
//
];
protected $dontFlash = [
'password',
'password_confirmation',
];
public function report(Exception $exception)
{
parent::report($exception);
}
public function render($request, Exception $exception)
{
dump($exception);
if ($exception instanceof UserNotVerifiedException) {
dump("Make Logout");
Auth::logout();
return redirect('/admin/dashboard/index');
}
return parent::render($request, $exception);
}
}
В файле дампа я вижу первое сообщение, но не второе (и почему нет перенаправления):
UserNotVerifiedException {#509 ▼
#message: "This user is not verified."
#code: 0
#file: "/mnt/_work_sdb8/wwwroot/lar/Votes/vendor/jrean/laravel-user-verification/src/Middleware/IsVerified.php"
#line: 26
trace: {▶}
}
Какой правильный путь?
Спасибо!