In this episode, we dive into a sneaky detail that comes up when using Laravel Fortify (or Jetstream, since it relies on Fortify) with email verification: by default, the verification email that's sent out includes the user's auto-incrementing database ID in the verification link. This might not sound like a big deal, but it can leak info about how many users your app has—something you might want to keep private!
First, we show exactly what this looks like by setting up a fresh Laravel Jetstream project and sending a registration verification email through MailTrap. Taking a close look, you'll see the user ID sitting right there in the URL.
To keep this info private, we walk through how to swap that exposed ID out for a UUID instead. That means creating a migration to add a uuid
field to your users table, setting up your User model to auto-generate a UUID for each new user, and making sure that the email verification process uses this UUID in the URL instead of the default ID.
We also dive under the hood to show how Fortify builds its verification links and where you need to override behavior in your User model. The result: the email sent to new users now contains a UUID, so you’re no longer giving away your user count (or anything else sensitive) by accident.
Perfect for anyone looking to make their Laravel app a little more private and professional!