php - 如何检查护照个人令牌是否已过期或被撤销?
问题描述
我正在使用 Laravel 作为我的反应应用程序的后端 API。如果令牌已过期或已撤销访问权限,我想返回错误消息。但是,在我的 Authenticate 中间件上,我只能捕获 AuthenticationException。此异常仅返回消息“未验证”。下面是我当前在 Authenticate 中间件中的代码
public function handle($request, Closure $next, ...$guards) {
try {
$this->authenticate($request, $guards);
} catch (AuthenticationException $e) {
$data['token'] = false;
return ResponseServices::error(__('Auth.token_expired', []))
->data($data)
->toJson();
}
return $next($request);
}
我尝试使用 OAuthServerException 和 Throwable 捕获异常,但无法捕获它。只能捕获 AuthenticationException。
但是,如果我在可报告函数的处理程序类中 dd Throwable,我能够获取此信息
是否可以在我的中间件中获取提示消息?
解决方案
推荐阅读
- php - 我的 PHP 表单的显示页面出现错误
- python - 我在 Spyder 中使用 pyproj 时出错,但在同一 conda 环境中的 Jupiter 实验室中没有
- java - 在 Spring Boot 中对大量请求使用 wait() / notify() 是个好主意吗?
- javascript - Gulp 相当于 webpack 外部
- swift - 在 SwiftUI 滚动视图中向后/向前滚动
- matlab - 如何将信号传递到频域?
- python - ElasticBeanstalk 部署失败:WSGI 无法作为 Python 模块加载
- firebase - 没有用户概念的 REST 授权
- adaptive-cards - 带有按钮的自适应卡放入 Bot Send Response 不等待响应
- git - 如何在 Github 上重新打开被拒绝的 PR