Unconfirmed Users Issue0:00
Let's knock out our first issue. In the last episode, we created one ourself. We noticed that if a User signs up and they haven't yet confirmed their account, so they haven't yet clicked on an email that verifies that it is in fact a real email address, well, they can try to create a new thread, go through all these steps, but if they publish it, they get, you must confirm your email address, and it basically ignores that. So, that's weird, right? We don't want to allow that. Instead, if you click on new thread, it should just automatically pick up on that fact. You're not confirmed, you can't yet do this. So let's fix that. In my code directory, if I go to routes/web, my routes file, you'll see right here, yeah, so if you fill out the form to create a thread, and you hit the endpoint for that form, well, we have this middleware called mustBeConfirmed.
Adding Confirmation Middleware0:44
you'll see right here, yeah, so if you fill out the form to create a Thread, and you hit the endpoint for that form, well, we have this middleware called mustBeConfirmed. And if we take a look at that middleware, let's go into here, redirectIfEmailNotConfirmed. That means before we hit the controller method, it's going to pipe it through this layer of the onion. And we check. Is the User not confirmed? Well, in this case, no, they're not confirmed. So if so, immediately redirect them, which means we never even get to the point of processing that new Thread form. We just immediately redirect them back to the overview page. So it sounds like, well, can we just add this middleware also to the page to create a new Thread? Like so. Let's see if that fixes it. So go to the homepage. Now I do want the User to see, oh, I can create a new Thread. But if they do it, there we go. They get the notification and
Testing Fix and Committing1:32
Like so. Let's see if that fixes it. So go to the homepage. Now I do want the User to see, oh, I can create a new Thread. But if they do it, there we go. They get the notification and they don't potentially waste their time. But if they do, click on the email to confirm their account. And they try to create a new Thread. Now they can. Okay. So that seems to be fixed. Require email confirmation for new Thread page. Now, when you have an issue that is associated with a Comment, you always want to reference that. So let's go back to Chrome right here. And what are we doing? We are resolving this issue with a number of two. So let's add that. Resolves. Issue number two. And this is nice. GitHub will pick up on that. All right. So commit that. Sync it. Or we can, of course, run a git push. Yeah. Anyways, if we come back in real time, you'll see that because we added that section that we are resolving the issue with a number of two,
