php - Resend email function causes 419 | Page Expired error in Laravel

I have this function for registering users which is pretty much the default one but i added a token to be sent to an email so the user can activate the account, otherwise the user cant log in. So i tried to add a resend function so if the first time the email is not send they can resend manually, but that causes the 419 error Page Expired.
Register function
protected function create(array $data)
{
$user = Account::create([
'login' => $data['login'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'verifyToken'=> Str::random(40),
'active' => (env('CONFIRM_EMAIL', true)) ? 0 : 1
]);
$thisUser = Account::findOrFail($user->id);
$this->sendEmail($thisUser);
return $user;
}
This is the function for resend
protected function resend(Request $request)
{
$user = Account::where('email', $request->input('email'))->first();
$user->verifyToken = Str::random(40);
$user->save();
$this->sendEmail($user);
return $user;
}
And i call it with this form
<form action=" {!! route('resendEmail') !!}" method="POST">
<fieldset class="youplay-input">
<input id="email" type="email" class="@error('email') is-invalid @enderror" placeholder="E-
mail" name="email" value="{{ old('email') }}" required autocomplete="email">
</fieldset>
<button class="btn btn-default db" type="submit" value="Submit">
Resend Verification Link
</button>
</form>
I have discussed this with a guy but we couldnt find a good solution: How to make resend email link function in Laravel
Answer
Solution:
You are missing your csrf token in the form. After<form>
tag add@csrf
.
Example:
<form method="POST" action="/profile">
@csrf
</form>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: sqlstate[hy000] [1698] access denied for user 'root'@'localhost'
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.