In this episode, we build out the user registration flow for the app! We start by creating a new view called Register
and, since registering is quite similar in structure to logging in, we copy over much of our login page as a starting point. Then, we update the register form to add the usual fields you'd expect—name, email, and password—tidying up the template and setting up routing to make it accessible.
Next, we connect the registration route and link it from the login page, so users can easily switch between signing in and creating a new account. We handle form submission with Axios, sending the data to our back-end, dealing with potential validation errors (like duplicate emails), and making sure these display nicely for the user.
A few small bugs pop up (like errors related to missing props), but we fix those along the way. One thing we highlight: after the registration API call, Laravel Fortify usually logs in the user behind the scenes, but our client needs to update its state, so we trigger an attempt to authenticate right after sign-up. Once that's in place, the user is redirected to their dashboard if everything goes smoothly.
We also make a quick detour on how to tweak Fortify's registration logic if we want to adjust password requirements or remove the need for password confirmation.
By the end, we've got a working registration process: users can sign up, are automatically logged in, and sent to their dashboard—ready to use the app!