This episode is for members only

Sign up to access "Build a Starter Kit With Inertia and Fortify" right now.

Get started
Already a member? Sign in to continue
Playing
37. Resending the verification email

Episodes

0%
Your progress
  • Total: 5h 21m
  • Played: 0m
  • Remaining: 5h 21m
Join or sign in to track your progress

Transcript

00:00
OK, let's figure out how we click this Resend Email button and get a new email sent to us if we didn't receive it.
00:07
OK, so we have a form out here. I think we'll just roll with using a form here. It's going to be much easier to just say Form Post and just post no data down.
00:16
But first of all, let's just check what this route looks like. So let's go over to our route list. And we have here a verification send route.
00:26
So that's probably the one that we want. Let's go over and add this in here. And to be honest, that should be pretty much what we need to do. So let's just try this out and see what happens.
00:38
So I'm going to hit Resend Email. And let's head over to our email here. And yeah, sure enough, that has been resend. Now, there's a bit of tidying up we can do here.
00:46
We could go ahead and just flash a message after this to tell the user that this has been resend. And we already know how to do that. We need to modify the response.
00:55
So let's dig into this and see what's happening. So we're going to go over to our Fortify routes. And let's find the email verification stuff here. So that looks like this one here.
01:08
We've got a route here with a controller. We open that controller up. And sure enough, we've got this email verification notification sent response.
01:18
So we're just going to copy that over, modify how this looks, and we can flash a message. So let's go up to our HTTP responses section. Let's add this in here.
01:28
Remember, we can do this for pretty much any route. We've probably missed some throughout the course. But by now, we pretty much should be able to do this ourselves.
01:35
So let's go over to our concrete implementation within Fortify. Again, it's just pretty much the same thing. So we're going to copy this over to our response and, of course, just modify it.
01:46
So first thing to do is switch over the namespace. And we'll go down here and just get rid of this JSON response because we're not going to need that. And we're going to return back with a flash message
01:58
or, what do we call that, toast. And email has been resent or, of course, whatever you want to say. So now we just need to hook this up over in our Fortify service
02:09
provider, and we are done. So let's go up to where we're registering all of these on our container. And let's grab the name for this.
02:16
It's quite long. So email verification notification sent response. And we're going to paste that in there and put in our own implementation of that
02:25
to bind it in. So now when we resend an email, sure enough, we get email has been resent. And remember, we can close off this modal programmatically
02:35
using the package that we're pulling in. And that's probably a good idea to do at this point. So let's go ahead and do that now. So once we have finished posting this through,
02:44
we're then going to say on success. And we can go ahead and invoke close, which we've got rid of. But we can just go ahead and pull that back in. So let's borrow that code from our modal.
02:56
Pull this in. Get rid of show because we're not going to need that. Get rid of redirect. And there we go.
03:02
We invoke that. That should close the modal. So let's go through the whole flow again, and then we should be pretty much done.
03:07
So over on home, I'm going to head over to dashboard. Of course, I haven't verified my email. I'm going to resend the email. The modal gets closed off.
03:14
We're redirected back, of course, because we can't access the dashboard. We get that email sent again. We hit verify email.
03:21
And there we go. We're landed back on the dashboard. And we can now access it. So that is email verification completely done now.
40 episodes5 hrs 21 mins

Overview

Let’s build our own Laravel starter kit with Inertia and include all the features you’d expect. We’ll implement authentication, email verification, profile photo uploads, two factor authentication, and more.

Fortify is a frontend agnostic authentication package for Laravel, meaning most of the work is done for us — we just need to build the frontend and make requests to the endpoints that Fortify registers.

Once you’re done, you’ll have a clean slate for building your next project, with the ability to control everything in your own starter kit.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.