We are going to implement password update and going to be the same as we did for the user details,
update for the password going to be easier as compared to the user details simply because when I click
on a link to display the form for me to update, we are not going to pre populate the existing password,
but for user details we did that.
The next one is that for password we are going to update one field.
So let's have a look.
Before we get into that, let's look at the controller.
So inside the controllers uses and let's locate the update password.
And this is the implementation and you can see that we are accepting only the password field.
So let's continue.
And for this, I don't want to find the user using the ID in the param, but instead I'm going to find
the user inside this session.
So I'm going to be as Rick dot session dot user auth.
Perfect.
So with this one, we need to make some changes to the route because now we have changed the params
to use the log in user ID and this is a route for update password.
So I'm going to remove this one.
The next step is that we need to have a button or an icon to click on.
So let's get to the profile.
That is a template.
And where we have these icons.
I want to add one icon here.
These are the icons.
So I'm going to add one here so I can copy one of these icons and then paste it here.
The icon for this is not this one, but instead f a solid.
And if it does key.
So let's have a look.
And you can see we have it as that.
But I want to have the same side.
So I'm going to add a class called F as.
And let's have a look.
And I have it as that.
Next one is I want to change the color to yellow.
I want to have inline styling that is color to yellow.
Next step is that when I click on this icon, I want to render the update password form and we are going
to use the log in.
So I'm going to duplicate this one and change the name to update.
Password.
And for this one, I'm going to remove the email.
And maintain the password only.
And this one is going to be as update.
And I'm going to remove this one from here.
And then for the form that is a you are or endpoint going to be API, use it forward slash update password.
So let me cross-check again inside the users root and it's called update password.
And question mark on that score method.
And I'm going to use put method, and I have the name here as that.
So let's go ahead and create one route to render the password form.
I can copy one of this one or I can use this one.
So let me bring back this one.
And for this one I'm going to be updating user password.
And then I went to render the update password.
All right.
So in next is let's use this.
You are an endpoint inside the profile.
So let's go to profile.
And for this one, I'm going to change this one to this.
All right.
So now when I click on the icon, I'm expecting to open the update password form.
So let's have a look.
Well, we have an error simply because we need to pass in the error properly into this.
So we're going to be as error and by default is empty.
So let's try again, refresh and click on that and we have the update password.
So let me change the title from log in to update password.
All right.
So now it's time for us to taste the actual request.
But before we get into that, let's try to display an error.
In case you're going to have one, let's go to use this controller.
And here we go.
So here, instead of ten in this JSON data, we are going to redirect and we can copy this code.
And in case we have an error, we are going to display the error.
So I'm going to copy this one also.
And down here, I'm going to pass it here.
And for the error, I want to get it from the error dot message.
Now, we'd be good to go.
So.
Moment of truth.
Let me go to profile.
And click on this icon and let me change to one, two, three, four, five, six update.
And it worked fine.
So let me look out now.
Let me log in back with the updated password for this one.
I use this user code email at gmail.com, and then the previous password was one, two, three, four,
five.
So let's have a look.
But if I use the updated password and that is one, two, three, four, five, six, let's have a look.
All right.
So it worked.
The next video, let's go ahead and then populate the user post.