Laravel 5 为什么未触发UserNotVerifiedException错误?

Laravel 5 为什么未触发UserNotVerifiedException错误?,laravel-5,verification,Laravel 5,Verification,在我的laravel 5.7.3应用程序中,我使用扩展和 未验证日志时生成UserNotVerifiedException错误的中间件 但有例外,我想注销并重定向到/login页面,然后在中读取文档 文件app/Exceptions/Handler.php I do: <?php namespace App\Exceptions; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandle

在我的laravel 5.7.3应用程序中,我使用扩展和 未验证日志时生成UserNotVerifiedException错误的中间件 但有例外,我想注销并重定向到/login页面,然后在中读取文档 文件app/Exceptions/Handler.php I do:

<?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);
    }
}
哪种方法有效


谢谢

您可以尝试放置原始名称空间,如:

if ($exception instanceof \Jrean\UserVerification\Exceptions\UserNotVerifiedException) {
    dump("Make Logout");
    Auth::logout();
    return redirect('/admin/dashboard/index');
}

您是否正在使用包
jrean/laravel用户验证
?是的,我在主题描述中提到过。
if ($exception instanceof \Jrean\UserVerification\Exceptions\UserNotVerifiedException) {
    dump("Make Logout");
    Auth::logout();
    return redirect('/admin/dashboard/index');
}