我正在尝试验证用户是否具有匹配的密码,但是当用户提交不匹配的密码The GET method is not supported for this route. Supported methods: POST.
时,我会卡在此错误中,但是如果密码匹配则可以正常工作,我该如何解决呢?
控制器
public function resetPassword(Request $request, $token)
{
$this->validate($request, [
'password' => ['required','confirmed'],
]);
$password = $request->password;
$tokenData = DB::table('password_resets')
->where('token', $token)->first();
$user = User::where('email', $tokenData->email)->first();
if ( !$user ) return redirect()->to('home');
$user->password = Hash::make($password);
$user->update();
Auth::login($user);
DB::table('password_resets')->where('email', $user->email)->delete();
return redirect()->to('/');
}
刀片
<form method="POST" action="{{ route('password.update',$token) }}">
@csrf
<div class="control">
<input id="password" type="password" name="password" required>
</div>
<div class="control">
<input id="password-confirm" type="password" name="password_confirm" required>
</div>
<button type="submit">
{{ __('Submit') }}
</button>
路线
Route::post('reset-password/{token}', 'Auth\ForgotPasswordController@resetPassword')->name('password.update');
答案 0 :(得分:0)
您需要更改此内容
[
{
"items": [
{
"name": "Fall Flavors Shop",
"url": "https://grocery.walmart.com/cp/Flavors%20of%20Fall/9576778812"
},
{
"name": "Baking Center",
"url": "https://grocery.walmart.com/browse?shelfId=3433056320"
},
{
"name": "Peak Season Produce",
"url": "https://grocery.walmart.com/browse?shelfId=4881154845"
},
# ...
与此:
<input id="password-confirm" type="password" name="password_confirm" required>
另外,请确保共享时视图底部缺少<input id="password-confirm" type="password" name="password_confirmation" required>
标签form
。
请确保您运行</form>
,以确保您的路由是唯一存在该端点的路由,并且方法类型也肯定是php artisan route:list
。