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
26. Confirming user passwords

Episodes

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

Transcript

00:00
so all we need to do now is go ahead and fill in the form that we have here and of course just send a request through to fortify to confirm the password, so let's go ahead and get started on our password confirm modal or confirm password modal and just go ahead and fill this in, okay so we're going to go ahead and steal some stuff from the login template so we'll grab the
00:22
password from here, I've also just noticed that we have errors.name there which we probably should change at this point so let's go ahead and grab the password from this and we'll wrap this in a form of course, we won't have an action there either and let's put that in there and we'll go ahead and grab the button from our login form as well, so let's find that button and just go ahead
00:43
and pull this over and we're just going to say continue in here and let's go up to the top here fill in the form stuff, so let's look for our form again and let's just pull in the class and the action for this as well, okay so we don't have a form in here at the moment so let's go ahead and create out a form, the only thing that we need to pass down when we're confirming a password is just a
01:09
password, so we'll go ahead and add the password in there and now we can just figure out where the root lives inside of our application, so we'll say php artisan root list again and sure enough we have a post to user slash confirm password which is password dot confirm, so very easily we can just swap this out here for that and we should be good because these are all hooked up because we
01:32
copied and pasted them over and let's try it out, so I'm going to head over to my dashboard and sure enough we have our password, let's go ahead and open up our network tab just to keep an eye on this, I'm going to go enter an incorrect password and sure enough we see the provided password was incorrect and then I'm going to go ahead and enter my actual password, hit continue and there we go
01:51
we are on our dashboard which is great, so now because this is stored in our session cookie we can just access this dashboard, now I'm going to talk quickly about how we can customize this behavior either if you need to customize the time for security reasons and also while we're developing we probably want to trigger this at some point without having to go into the storage
02:13
section of our browser and deleting the cookies and logging us out, so how do we customize this, well let's dive into the source for this and just see what we have, so if we go over to our kernel again let's have a look at this require password middleware once again, so if we come down here we've got the password timeout, we're not going to do that in the constructor because we don't modify
02:34
the construct within our middleware, we've got this using as well which is probably going to be useful to set the password timeout seconds and we've got the signature of this as well, now because this is a null value we can't pass this down as a string within our middleware stuff by that I mean if we head over to our web roots and we try and do something like null and then one
02:54
as the second timeout, null is a string value so it's not quite going to work here, it's not going to set that as a default of null, so this will probably just completely break this functionality and just not work, so what we're going to do is use this using static method and reference the middleware directly, so let's find out what that's called require password, so let's say
03:17
require password using say null for the redirect and then we'll say one for the timeout just in here, so this is just an alternative way of using middleware, so let's go over give this a refresh we've got one second timeout now for our password confirmation, so there we go it's allowing us or showing us the password confirmation modal, I can click through to continue but the next time I do
03:39
it because we have that one second delay it's showing it again, so this is helpful for obviously high security applications where you need to continually ask the user for their password probably not every one second but we can decrease that but it's also really useful for debugging as well so we can switch that timeout over so we can continue to see this modal even once we've
04:01
confirmed our password, okay so I'm going to get rid of that I'm just going to put it down here as a note so we've got that and that's pretty much it we can now access an area once we've confirmed our password we don't need that for our dashboard but when we move on to our two-factor authentication this modal is going to be automatically triggered but we now have it so we're good to go.
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.