当前位置:网站首页>Larave8 JWT API expiration custom error return
Larave8 JWT API expiration custom error return
2022-06-30 14:18:00 【Meimei Technology】
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
use Illuminate\Auth\AuthenticationException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Throwable
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
if ($exception instanceof RouteNotFoundException) {
return response()->json(['status'=>401, 'msg'=> 'Token invalid , Log back in ']);
}
if ($exception instanceof AuthenticationException) {
return response()->json(['status'=>401, 'msg'=> 'Token Be overdue , Log back in ']);
}
return parent::render($request, $exception);
}
}
边栏推荐
- With the development of industrial Internet, the landing and application of the Internet has become wider
- Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)
- 提权扫描工具
- numpy 创建空数组 data = np.empty(shape=[1, 64,64,3])
- Go language mutex lock
- QQ was stolen? The reason is
- Race of golang
- Click the TD cell of table to open the dialog pop-up window. After obtaining the value, put the value back into the TD cell
- 重磅:国产IDE发布,由阿里研发,完全开源!
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
猜你喜欢

单元测试效率优化:为什么要对程序进行测试?测试有什么好处?

Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit

“即服务”,企业数字化转型的必然选择
![[Title brushing] coco, who likes bananas](/img/66/5646ac7e644025ccaee7c17f62ce17.png)
[Title brushing] coco, who likes bananas

Step by step | help you easily submit Google play data security form

Shell programming overview

Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone

Pytoch viewing model parameter quantity and calculation quantity

MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video

Detailed explanation of the first three passes of upload Labs
随机推荐
Je suis à Foshan, où puis - je ouvrir un compte? L'ouverture d'un compte par téléphone mobile est - elle sécurisée?
More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked
Jetpack compose for perfect screen fit
Rpm2rpm packaging steps
Configuration of headquarters dual computer hot standby and branch infrastructure for firewall Foundation
[the path of system analyst] Chapter 5 Software Engineering (Agile Development)
Geoffreyhinton: my 50 years of in-depth study and Research on mental skills
Laravel RBAC laravel permission use
Shell programming overview
Wechat applet realizes map navigation + door-to-door recycling
Use of laravel repository mode
SQL attendance statistics monthly report
(8)JMeter元件详解之 Once only Controller 仅一次控制器
ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
提权扫描工具
Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)
Detailed explanation of the first three passes of upload Labs
Logiciel de récupération de données easyrecovery15 téléchargement
Advanced usage of go language for loop break and continue
"Persistent diseases" that cannot be solved in IM application development