vincent15000's avatar

Problem with Fortify and email verification ?

Hello,

Is there any problem with Fortify v1.27 ?

When I create a new user via the registration form, I receive an email with a link to verify the email.

When I click on the link, I am redirected to the login page and email_verified_at is not updated with the date.

I regularly use Fortify and it's the first time I get this behavior.

Thanks for your help.

V

0 likes
16 replies
Snapey's avatar

You must be logged in to verify the email address.

This also means that the browser that opens when you click the link, must be the same one that has your logged in session.

1 like
vincent15000's avatar

Yes it's the case.

Hmmm ... When I register, I'm using the fortify routes, I type the name, email, ... I click on the register button and I am redirected to the email/verify URL.

Then I check my emails, I click on the verification button (email/verify/{id}/{hash}) and I am redirected to the login page.

I really don't understand why.

vincent15000's avatar

I just checked something.

When I click on the link, it doesn't work.

But if I copy / paste the link in the browser, then it work.

Why ? What happens ?

Snapey's avatar

because when you click the link in the email you are using a different browser?

Or your registration session is in private browsing mode?

1 like
vincent15000's avatar

I'm using the database session driver.

Could it be the problem ? But it were the problem, it would also not work when I copy / paste the link.

Snapey's avatar

unlikely to be the issue. Assuming the link is identical, whether you click on it or paste it, then its down to whether the app recognises you are the same session, which is done via cookies in the client.

1 like
vincent15000's avatar

@snapey @rihulfaakbar

I get this in the Laravel debugbar in the session when I copy / paste.

array:1 [
  "intended" => "http://localhost:8000/email/verify/01kjm7h6q1p180x5t0mvdehdh2/89c321e779a4d18b15501669f7a1027e9c386706?expires=1772356789&signature=55cc2866b5ca2e194f1b0f8f67f62a53a5c26bfd0c7443864391049cf35b977d"
]

But when I click on the link, I only the the token and nothing else.

vincent15000's avatar

@snapey @rihulfaakbar

Perhaps a useful information, but I don't know what I can do with it.

When I open the registration page, one session is stored in the database.

When I click on the link received by email to verify my email, 2 additional sessions are created in the database.

Snapey's avatar

what is the link exactly?

1 like
vincent15000's avatar

It's the link generated by Fortify to confirm the email address.

http://localhost:8000/email/verify/01kjm9cvjk50mjqdy7szxgch23/42e975cfc909dfab843a80f39bbc8d88f44eda62?expires=1772358589&signature=548a6249146b5da814726f0e8c2fd6ef47e8f21f547ac8248b630a935afdf794

Before I click on the link, I can refresh the page http://localhost:8000/email/verify several times, the same page is reloaded.

After I have clicked on the link, if I refresh the page, I am redirected to the login page. So when I click on the link, Laravel logs out the user.

vincent15000's avatar

Here it is ... I just solved it.

It was in my session configuration.

I had : SESSION_SAME_SITE=strict and I changed it to : SESSION_SAME_SITE=lax.

Snapey's avatar

Is your app_url matching the install?

1 like
vincent15000's avatar

I have set the APP_URL in the .env file to http://localhost:8000.

Sure it won't be the same in production ;).

Please or to participate in this conversation.