php - Laravel问题从电子邮件验证传递错误消息
问题描述
我想寻求帮助,因为我不知道如何告诉用户激活链接不正确。
我覆盖了验证方法,现在,成功激活后,用户会收到信息。但是当链接无效时得到 403 | 无效的签名。
我已经没有想法了,我想将消息的形式更改为登录页面上显示的引导警报
protected $redirectTo = '/login';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
public function verify(Request $request)
{
$user = User::find($request->route('id'));
if (!hash_equals((string) $request->route('hash'), sha1($user->getEmailForVerification()))) {
throw new AuthorizationException;
}
if ($user->markEmailAsVerified())
event(new Verified($user));
return redirect($this->redirectPath())->with('verified', true);
}
我试过try catch,但没有奏效
任何人都知道如何实现这一点?我正在使用 Laravel 8
解决方案
您可以检查签名是否有效,然后重定向或添加有效负载。
if (!$request->hasValidSignature()) {
// do stuff here (return view, redirect etc)
}
推荐阅读
- sql - 带有月份和年份的 SQL Pivot
- python - 如何使用 python 库 - 在 google colab 中导入 webbrowser?
- r - 选择并填充 jpg 中的随机像素
- javascript - 使用来自子组件的数据从组件调度操作
- javascript - 如何使用 jquery 从数字中拆分后缀?
- python - 绘制缺少日期值的时间序列信息
- http-post - 无法从 Microsoft Teams 消息卡的 potention 操作按钮发送 http 发布请求
- flutter - 颤振:CupertinoActivityIndicator 不再工作
- mysql - 如果mysql中所有相应的ID都相同,如何删除所有行?
- linux - 如何在绝对路径中的目录之间导航