我无法为同一电子邮件地址重设两次密码,第一次我可以重设密码,第二次我单击密码重设链接时,它显示空白页面并将我重定向到主页url,但我不知道发生了什么,但是如果我多次在同一个电子邮件地址上发出请求,则可以在本地正常工作,我可以成功重置本地密码,但是如果我已经重置了密码,则无法实时重置密码。
我还附上了我的视图的屏幕截图:
我的控制器:
public function forgot(Request $request)
{
$user = User::where('email', $request->email)->first();
if (!$user) {
return response()->json([
'success' => false,
'message' => "Your email address was not found.",
], 401);
}
try {
$token = str_random(64);
DB::table('password_resets')->insert([
'email' => $request->input('email'),
'token' => bcrypt($token),
'created_at' => Carbon::now()
]);
$user->reset_token = $token;
Mail::to($user->email)->send(new ForgotPassword($user));
} catch (\Exception $e) {
//Return with error
$error_message = $e->getMessage();
return response()->json([
'success' => false, 'errors' => $error_message], 401);
}
return response()->json([
'success' => true, 'message' => 'A reset email has been sent! Please check your email.'
]);
}
我的重置密码控制器:
class ResetPasswordController extends Controller
{
use ResetsPasswords;
}
我的路线:
<?php
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.request');
Route::get('/home', 'HomeController@index')->name('home');
家庭控制器:
class HomeController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
return view('home');
}
}
我的forgot.blade.php
<html>
<head>
<title>Welcome Email</title>
</head>
<body>
<h2>Hello {{$user['first_name']}}</h2>
<br/>
You are receiving this email because we received a password reset request for your account.
<br/>
<a href="{{url('password/reset', $user->reset_token)}}">Reset Password</a>
<br/>
<p>
If you did not request a password reset, no further action is required.<br/>
Regards,<br/>
<strong>Triple R Lense</strong>
</p>
</body>
</html>
我所看到的: