I'm trying to redirect the user back to the previous page if the token entered is invalid but i'm getting the error "The GET method is not supported for this route. Supported methods: POST."
Everything works well when the token is valid. Here is my code
ForgotPasswordController
public function showPasswordResetForm(Request $request)
{
$inputToken = $request->token;
$tokenData = DB::table('password_resets')
->where('token', $inputToken)->first();
if (!$tokenData) return redirect()->back()->withErrors(['token' =>
'Token doesnt exist']); //redirect back if the token does not
exist.
$token = $tokenData->token;
return view('auth.passwords.reset')->with('token', $token);
}
Route
Route::get('reset-password/{token}', 'Auth\ForgotPasswordController@showPasswordResetForm')->name('check.token');
Blade
<form method="POST" action="">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right"></label>
<div class="col-md-6">
<input id='token' type="text" class="form-control @error('token') is-invalid @enderror" name="token" required autocomplete="token" autofocus>
@error('token')
<span class="invalid-feedback" role="alert">
<strong></strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
</button>
</div>
</div>
</form>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire