In this episode, we finally wire up our user registration logic! We start off with the data we collected from our registration form, and — using Sentinel, which we've already set up — we register a new user. You'll see how we can easily access Sentinel from our container and use it to call methods like register
or register and activate
.
We keep things simple for now: no validation or error handling is done yet (we'll get to that soon). We're also skipping email activation for the moment and just activating the account automatically.
Once a user is registered, we look at how to redirect them immediately to the dashboard using a redirect response. Then we try it out: register a new account, watch the redirect happen, and take a look at the database to confirm the user (and their hashed password!) is there.
After registration, we realize the user isn't technically signed in yet, so we go back and update the code to log the user in as soon as they're created. We make a quick change, re-test, and see that the session cookie indicates the user is now logged in.
By the end of this episode, our app can register users and immediately log them in. There's still work to do (like validation and error-handling), but we're up and running. Next up: we'll update the navigation to reflect the new authentication state!