密码重置链接的生存期在laravel中不会过期

时间:2019-12-05 10:06:24

标签: php laravel laravel-5.8

我创建了ResetPassword.php的本地化副本,并在sendPasswordResetNotification ()中重新定义了app\user方法。一般来说,我会按照规则做所有事情(我认为是))。所有的规则都会给邮件发送一封信,但是只有一个问题。此链接不会过期。默认情况下,有60分钟,此后链接应该被销毁。但这不会发生。在我的代码下面将感谢您的帮助。

 <?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class mytelresetpassword extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($token)
    {
        //
        $this->token = $token;
    }

    /**
     * The callback that should be used to build the mail message.
     *
     * @var \Closure|null
     */
    public static $toMailCallback;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        if (static::$toMailCallback) {
            return call_user_func(static::$toMailCallback, $notifiable, $this->token);
        }

   $time = ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')];
   $time = $time['count'];

        return (new MailMessage)
                    ->subject('Şifrənin Dəyişdirilməsi')
                    ->line('Hesabınızdan şifrə yeniləmə tələbi aldığımız üçün bu mail sizə göndərilib.')
                    ->action('Şifrəni Yenilə', url(config('app.url').route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false)))
                    ->line('Bu link '.$time.' dəqiqə müddətində keçərlidir, bu müddət bitdikdən sonra deaktiv olunacaq!')
                    ->line('Şifrə dəyişməyi tələb etməmişsinizsə,   "Şifrəni Yenilə"  düyməsini klikləməyə ehtiyac  yoxdur.');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }

    /**
     * Set a callback that should be used when building the notification mail message.
     *
     * @param  \Closure  $callback
     * @return void
     */
    public static function toMailUsing($callback)
    {
        static::$toMailCallback = $callback;
    }
}

app\user中:

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

1 个答案:

答案 0 :(得分:0)

我建议在您的ResetPasswordController.php中添加几行:

(Get-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com") 
相关问题