为什么没有触发 UserNotConfirmedException 错误?
Why UserNotVerifiedException error is not trigered?
在我的 laravel 5.7.3 应用程序中,我使用 https://github.com/jrean/laravel-user-verification 扩展并使用
中间件我在未验证记录时生成 UserNotVerifiedException 错误
但是我想注销并重定向到 /login 页面并阅读 https://laravel.com/docs/master/errors#the-exception-handler doc
文件 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: {▶}
}
哪种方式有效?
谢谢!
你可以试试把原来的命名空间放成这样:
if ($exception instanceof \Jrean\UserVerification\Exceptions\UserNotVerifiedException) {
dump("Make Logout");
Auth::logout();
return redirect('/admin/dashboard/index');
}
在我的 laravel 5.7.3 应用程序中,我使用 https://github.com/jrean/laravel-user-verification 扩展并使用 中间件我在未验证记录时生成 UserNotVerifiedException 错误 但是我想注销并重定向到 /login 页面并阅读 https://laravel.com/docs/master/errors#the-exception-handler doc 文件 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: {▶}
}
哪种方式有效?
谢谢!
你可以试试把原来的命名空间放成这样:
if ($exception instanceof \Jrean\UserVerification\Exceptions\UserNotVerifiedException) {
dump("Make Logout");
Auth::logout();
return redirect('/admin/dashboard/index');
}