Adding Subscribers

Saving and verifying subscribers - Part Three

Summary

Coming soon.

Transcript

We need one more handler and that's the handler that's gonna handle the error cases where we show the we could not validate you, please request a new token. And this one is gonna look very similar to the subscription create handler we just made, right? So I'm just gonna copy paste it here. Save. And then we're gonna go through it, right? So we still accept an email, we pass it, we begin the transaction, get this email. And then instead of creating a subscriber, we just get the subscriber, create a new token, we send the validation email back to them, which is gonna be the same email as the one we're gonna send in the original flow, commit the results and then return a subscription response message. So this one very similar to our create, the only difference is we don't create a subscriber, we only create a new token for the subscriber with that email. And of course, if there's no email for the provided email they provided, you know, we are so far down the rabbit hole that they will probably just go back and try originally again. So we could return that. Yeah, that's it. But this is a very robust flow. We deal with a lot of the cases. And yeah, this is all the elements we need to start accepting subscribers and having them validate their emails. One final thing, we need to add our new controllers to our routes. So let's go into routes here. And under the load app, we are gonna be adding the just at the post here, we're gonna add the slash subscribers. And we don't need to add middleware, we need to just return our subscriber create controller pass the echo context. There we go. Then we also need to have a get that goes to slash subscribers email verify. Again, that just returns our CTIO, our subscriber subscriber email verify handler, then we also need another post here for our subscription validation token. Don't know why this word is so hard for me. Nope, we don't need that re post that's correct. We need a regular there we go. There we go. Let me need to return the subscriber verification token handler. Finally, in our fragments, let's just register our subscription form fragment, our subscription form as a fragment so we can return that with HTMX subscription form. We're gonna pass the func. No, it's weird. It keeps doing this. Funk. I'm just gonna grab this up right here. Hopefully, it will play a little bit nicer. And it's gonna be our subscription subscription. Do we actually not have a form? We have not created our subscriptions form fragments. Okay, so back into controllers. Let's create this really quick. We shouldn't really need that much since we only need to return views subscription form and CCSRf token request render and arcs CTX. So there we go. Now if you go back, yeah, the output. So I like to register fragments whenever we can call them in the way we call the subscription form. So that these fragments gets reusable. Now, the final thing we need is we need to add the emails, we need to create the emails, we just need to create a client that can send emails and then we can actually finish up the controllers and start testing our subscription flow.

Early Access

$95 $65 USD

Get access

Invoices and receipts available for easy company reimbursement