簡體   English   中英

在Laravel 5.5中接收錯誤的重置密碼鏈接

[英]Receiving a wrong reset password link in Laravel 5.5

我在我的項目中使用php artisan make:auth,除了發送的重置密碼鏈接外,一切都很完美。 該鏈接未包含正確的URL,錯過了項目名稱。 這是在我進入通知解決方案之前發送的鏈接: http:// localhost / password / reset / 05929a8e465ddfa123a4c068da455cf63c3b9b90ec500a0e1045f092bbd0d97a我在User類中創建了此方法:

public function sendPasswordResetNotification($token) {
    $this->notify(new ResetPasswordNotification($token));
}

然后我創建了一個包含toMail方法的通知類來覆蓋\\ vendor \\ laravel \\ framework \\ src \\ Illuminate \\ Auth \\ Notifications \\ ResetPassword.php中的現有方法:

class ResetPasswordNotification extends Notification {
use Queueable;
...
...
    public function toMail($notifiable) {
    return (new MailMessage)
        ->line('You are receiving this email because we received a password reset request for your account.')
        ->action('Reset Password', route('password.reset', $this->token))
        ->line('If you did not request a password reset, no further action is required.');
}

我現在獲得的鏈接按預期工作,這是發送的鏈接: http:// localhost / myproject / public / password / reset / 435e453cfa30c968c96ded21c964d70e21459d6ae6ffae8f4972c229773e8a6a 但是,我不知道我是否直接在ResetPassword.php中更改了toMail方法,而不是通過通知進行操作會導致生產中的任何問題或其他問題,我只會更改 - >動作部分。

非常感謝。

在Laravel 5.5中,內置通知使用以下代碼構建URL:

url(config('app.url').route('password.reset', $this->token, false)))

可以通過在.env文件中設置APP_URL變量來更改config('app.url')的值。 如果設置APP_URL值,則無需APP_URL覆蓋內置功能。

APP_URL=http://localhost/myproject/public

config/app.php

更改

'url' => env('APP_URL', 'http://localhost'),

至:

'url' => env('APP_URL', 'http://wwww.yourwebsite.com'),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM