[英]Laravel 9 email verification Invalid Signature
I've read all available solutions, but no chance.我已经阅读了所有可用的解决方案,但没有机会。 It always redirects to the 403 page with message (Invalid Signature).
它总是重定向到带有消息(无效签名)的 403 页面。
Here is my route:这是我的路线:
Auth::routes(['verify' => true]);
My env file:我的环境文件:
APP_NAME='WebApp'
APP_ENV=local
APP_KEY=base64:V4/NjIiHJMalSGiXqCfzDJJVF4BfDwJ8Hnxr1M8I2Lc=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
MAIL_MAILER=log
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
But the provided link in log file is always invalid.但日志文件中提供的链接始终无效。
I'm using built in artisan sever php artisan serve
我正在使用内置的工匠服务器
php artisan serve
Update: This is the link in laravel.log
file.更新:这是
laravel.log
文件中的链接。
http://127.0.0.1:8000/email/verify/2/52e17b67fd82b0545bb4fbdc5748ed23104133c7?expires=3D1652547054&signature=3De8f38349c57d806fb67170ceee8e7300cbc40d61133e1f70c7929e843401db6a
I have tried php artisan key:generate
and php artisan config:cache
我试过
php artisan key:generate
和php artisan config:cache
The email is being send by laravel itself, I haven't customized anything. email 是 laravel 自己发送的,我没有定制任何东西。
Also I tried to override verify method provided by VerifiesEmails.php
trait, but no chance.我也试图覆盖 VerifiesEmails.php 特征提供的
VerifiesEmails.php
方法,但没有机会。 Here is what I did:这是我所做的:
VerificationController.php
: VerificationController.php
:
public function verify(Request $request) {
dd($request->fullUrl());
}
I got suspicious to the url according to some solutions but the url is all fine like above mentioned.根据一些解决方案,我对 url 产生了怀疑,但 url 一切正常,如上所述。
After struggling 9 hours with this and hitting my head against the wall;在为此挣扎了 9 个小时并将我的头撞到墙上之后; finally I found out that the SIGNATURE is fine, but when laravel logs it in
laravel.log
file, it corrupts the file content and prefixes the SIGNATURE with this 2 characters 3D
.最后我发现 SIGNATURE 没问题,但是当 laravel 将它记录在
laravel.log
文件中时,它会破坏文件内容并在 SIGNATURE 前面加上这 2 个字符3D
。
This way everything breaks;这样,一切都破裂了; I don't know why is this happening.
我不知道为什么会这样。
I won't delete this question in case others face this problem in future.我不会删除这个问题,以防其他人将来遇到这个问题。
Man, you have just saved me this whole process.伙计,你刚刚拯救了我整个过程。
In my case the PhpStorm also added =
to the end of every line and 3D
was also in expire=
在我的情况下,PhpStorm 还在每一行的末尾添加了
=
并且3D
也在expire=
Thank you very much非常感谢
For anyone still running into this issue try configuring the TrustProxy
middleware if you have a similar configuration to the below对于仍然遇到此问题的任何人,如果您具有与以下类似的配置,请尝试配置
TrustProxy
中间件
URL::forceScheme('https');
URL::forceScheme('https');
in the boot
method of AppServiceProvider
AppServiceProvider
的boot
方法中 To get this working quickly, set the below in TrustProxies.php
middleware.为了快速完成这项工作,请在
TrustProxies.php
中间件中设置以下内容。
protected $proxies = '*';
For more information on configuring the $proxies
setting, check out the official Laravel documentation here有关配置
$proxies
设置的更多信息,请在此处查看官方 Laravel 文档
In my case, I was using Job Batches which have their own table in the database.就我而言,我使用的是 Job Batches,它们在数据库中有自己的表。 There was an issue with one of the rows not having run and the exception message did mention
BusBatch
(something like that).其中一行没有运行时出现问题,异常消息确实提到
BusBatch
(类似的东西)。 To solve, I simply deleted the record from the database.为了解决,我只是从数据库中删除了记录。 Prior to noticing this issue, in Horizon, the batches tab would not get passed the loading circle.
在注意到此问题之前,在 Horizon 中,批次选项卡不会通过加载循环。 So if you're working with jobs and batches, this could be a lead.
因此,如果您正在处理作业和批次,这可能是一个线索。
I never encountered this problem before and seems like it could stem from many other things.我以前从未遇到过这个问题,似乎它可能源于许多其他问题。 Hope this is helpful.
希望这会有所帮助。
I had the same case as you, i tried the following and it worked我遇到了和你一样的情况,我尝试了以下方法并且有效
Find folder app/Http/Controllers/Auth/VerificationController.php
找到文件夹
app/Http/Controllers/Auth/VerificationController.php
public function __construct()
{
$this->middleware('auth');
// $this->middleware('signed')->only('verify'); // -> change
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
I hope it helps you我希望它能帮助你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.