In this episode, we're setting up user registration for our app and exploring a couple of different ways to handle it. You could go the traditional route by having users pick a password, or you could go with a more modern approach—just grab their name and email, then send them a magic login link. We're trying out the latter to keep things simple and see how it works in Laravel.
We start by duplicating our login template to make a register.blade.php
template, tweaking it to collect the user's name and email instead of a password. We also make sure it's hooked up to the right route and is only available to guests (people not already signed in). With that in place, we test loading up the registration page to ensure everything looks good.
From there, we dive into the backend. Since we've got the Laravel actions package installed, we whip up a new CreateUser
action. This handles the incoming registration request, validates the email and name (making sure the email is unique and all fields are filled in), and creates a new user in the database. We also show how to customize the migration so the password field isn't required (since we're using magic links, no password needed!).
With validation and saving to the database working, we try it all out: register with a new email and name, and we can see the new user pop up in the database. One bit to note—we're not actually sending the email with the magic link yet. That's coming up next, where we'll reuse the magic link action we made earlier, tying it all together for a seamless registration and login experience without passwords.
In short: in this episode, you learn how to build a basic registration system in Laravel for magic link authentication, setting the stage for actually sending login emails next.