Сброс пароля не работает в Laravel 5.4

Я новичок в Laravel. Я хочу реализовать логин и регистрацию, используя авторизацию laravel. Я успешно выполнил вход в систему и зарегистрировался, но не могу выполнить сброс пароля.
Я сталкиваюсь со следующей проблемой:
1. После отправки имени пользователя / электронной почты происходит некоторая обработка, но я не могу отправить ссылку для сброса пароля по электронной почте. У него всегда был экран с сообщением о том, что мы отправили вам ссылку для сброса пароля по электронной почте, но ничего не происходит. Записи делаются в таблице password_resets.
Любая помощь будет высоко ценится.

Я использую Gmail для отправки писем для сброса пароля. После многих отладок все выглядит хорошо, кроме файла ResetPassword.php, который выполняется до

public function via($notifiable)
{
// echo "<pre>".print_r($notifiable,1)."</pre>";exit("<br/>sdds");
return ['mail'];
}

В этом файле есть функция, которая создается для отправки электронных писем, но эта функция не вызывается. Функция приведена ниже:

 /**
* Build the mail representation of the notification.
*
* @param  mixed  $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
echo "<pre>".print_r($notifiable,1)."</pre>";exit();
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.');
}

Вот основной файл, используемый в этом

Класс модели авторизации RetailUserAuth.php

    <?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Auth\Passwords\CanResetPassword;
class RetailUserAuth extends Authenticatable
{
use Notifiable;
//protected $primaryKey = 'user_id';
protected $table = 'retail_user_auth';
public $timestamps = false;
protected $fillable = ['username', 'user_id', 'password','source','user_status'];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}

SendsPasswordResetEmails.php

  <?php

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;

trait SendsPasswordResetEmails
{
/**
* Display the form to request a password reset link.
*
* @return \Illuminate\Http\Response
*/
public function showLinkRequestForm()
{
return view('auth.passwords.email');
}

/**
* Send a reset link to the given user.
*
* @param  \Illuminate\Http\Request  $request
* @return \Illuminate\Http\RedirectResponse
*/
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['username' => 'required|email']);

// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('username')
);

//echo "</pre>".print_r($response,1)."</pre>";exit();
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($response)
: $this->sendResetLinkFailedResponse($request, $response);
}

/**
* Get the response for a successful password reset link.
*
* @param  string  $response
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetLinkResponse($response)
{
return back()->with('status', trans($response));
}

/**
* Get the response for a failed password reset link.
*
* @param  \Illuminate\Http\Request
* @param  string  $response
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetLinkFailedResponse(Request $request, $response)
{
return back()->withErrors(
['username' => trans($response)]
);
}

/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker();
}
}

CanResetPassword.php

    <?php

namespace Illuminate\Auth\Passwords;

use Illuminate\Auth\Notifications\ResetPassword as
ResetPasswordNotification;

trait CanResetPassword
{
/**
* Get the e-mail address where password reset links are sent.
*
* @return string
*/
public function getEmailForPasswordReset()
{
return $this->username;
}

/**
* Send the password reset notification.
*
* @param  string  $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
}

ResetPassword.php

   <?php

namespace Illuminate\Auth\Notifications;

use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class ResetPassword extends Notification
{
/**
* The password reset token.
*
* @var string
*/
public $token;

/**
* Create a notification instance.
*
* @param  string  $token
* @return void
*/
public function __construct($token)
{
//echo $token;exit('<br/>fdfdffd');
$this->token = $token;
}

/**
* Get the notification's channels.
*
* @param  mixed  $notifiable
* @return array|string
*/
public function via($notifiable)
{
// echo "<pre>".print_r($notifiable,1)."</pre>";exit("<br/>sdds");
return ['mail'];
}

/**
* Build the mail representation of the notification.
*
* @param  mixed  $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
echo "<pre>".print_r($notifiable,1)."</pre>";exit();
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.');
}
}

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector