protected function verificationUrl($notifiable) {
return URL::temporarySignedRoute(
'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
);
}
此函数根据所有$notifiable
json数据创建URL。传递到电子邮件。
$this->verificationUrl($notifiable)
使用此URL和实际的电子邮件验证与其他redirectTo
参数一起使用时,我的成功率为零。每当我尝试添加此参数时,所有验证过程都会停止。只是感觉不允许添加其他东西。
我可以存储一个cookie,该cookie将在验证后使用,但是在技术上是否有使用VerificationController
来执行此操作的更正确方法?
protected $redirectTo = '/';
public function __construct() {
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
尝试:
protected function verificationUrl($notifiable) {
return URL::temporarySignedRoute(
'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
).'&redirectTo=https://root.loc/whatever';
}
我什至尝试解析生成的URL(不带附加参数),然后插入其他位置。但是,仍然没有成功。
答案 0 :(得分:1)
您在错误的位置添加了参数。它应该在传递给URL :: temporarySignedRoute()的第三个参数的数组中:
protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(60), [
'id' => $notifiable->getKey(),
'redirect_to' => route('foo')
]
);
}