Hi everyone.
After we already.
Ask the rose property into the user collection.
We need to do the authorization right now before writing the code.
Let me show you what the idea first.
Okay, I want to show you what we need to do for our polarization in laser inside the ground right here.
I will use one more goal will be authorization draw.
Okay.
For example, like that.
And?
Actually, this is the ruler.
Okay.
It's much better.
And furthermore, in order to create a new new user, I want only the admin can create the new user.
Okay, so for that reason I want to boost something like this to be row with admin.
Okay something like that.
And inside the file own method.
Also I want only the admin can find all users.
And here will be the same with the admin.
Or actually.
I want the admin and user can also find the user.
Okay.
But the admin right here can find any user if that means one and the users can only access into belong
that user.
Okay.
For example right here we will add, for example, we have a user one hot and one we have user to have
a little okay.
The admin can find the user one with the ID right here, or user two if that means one okay.
But the normal user for example, when I logged in I logged in with the user one.
It means I only can access to my profile.
Okay.
I cannot be able to access it to the another profile.
That's what I want to build the version for the users okay.
And this will be the same with update okay.
I want the admin can update any account okay.
But user can only update um on account.
Right.
And the list will be also okay.
That's what we want right now.
Let me show you How to do last.
Now, right here inside the course, I will create one more row with authorization graph.
Sorry.
Row, row plus these.
And I need to copy this.
Right.
Inside the for loop.
Sorry.
Is that a overview of GA and copy everything.
And change row row row and row.
Here let's replace with a retro okay.
And we already have a row GA.
So how about The custom decorator.
Let me show you.
If you click inside the security, click on authorization.
We will scroll a little bit.
Give you say right here we will define a new decorator with the row okay.
We will use we will use the set metadata from.
Net yes.
And we will put a key a value okay.
Right now let's go with me and I will explain that for you.
What exactly about we set metadata.
So now let's create the decorator.
Row decorator.
Yes.
And I will copy everything over here so that we can remove the row.
Right here.
Let's replace it with only screen.
And.
Obtain the screen right here is not good.
If you are going to keep my USA, does the rotor here only have user and admin software inside the global?
I will define the new in the file.
I row.
I'm ready for the pass.
Okay we will admin.
Okay.
Like this.
And I will use that directly into the user schema over here.
It will be totally the same okay.
And right now inside the decorator I click give you a row over here with a row.
Okay.
We will divide the rows like this.
It means it will row right here.
Okay.
Very easy.
So after we already got the rows right here, let's replace this.
He brought us.
Okay, this will be work.
And let me explain for you what exactly about set metadata?
Okay.
The metadata is decorator.
Okay.
It already written by Next.js.
So what?
What is made row here?
First of all, inside the controller we will use decorator right here in the method.
Okay.
It may.
It will somehow generate no metadata for specific method.
Okay.
Let me show you what I mean.
You can see the result of the segment and that will be somehow like this.
Okay with me.
If you say right here the case.
Right here, it will become somehow like the row case, right?
It will become somehow this rows and right here it will boost the method possible like five one.
And right here it will boost the row like mean okay.
And user okay.
And maybe in the create method it will create only that mean okay it will somehow create something like
this.
Okay.
This is the.
Image.
With the set metadata.
It will create the metadata for specific methods.
Okay.
And it only exists in the runtime.
Okay.
When we bootstrap or when we start the application, it will create the structure like this for you.
Okay.
That's about metadata.
And for that reason we can retrieve that okay.
Of course when we set that we can achieve that using this split.
Why.
Let me say.
Let me find somewhere.
We can retrieve that.
Here.
Okay.
We can use this.
Why?
We can find us in the execution context and click into the reflection and metadata.
Okay, you can see.
Right here we can search like that.
And it also get us, you say this dot reflector and we will pass the, uh, the case.
Okay.
And we need to pass the context of the handler.
Okay.
This will be return for use the method okay.
It will return for you the method name okay.
For example like firewall okay.
Or something like that.
So that's with this way we can retrieve that.
Let me show you inside the controller we need to inject the reflector.
Right.
Right here we can invoke that.
Inside here let.
Private flat.
And let's say.
And after that, let me show you.
I will copy paste this line of code.
I'm not remember.
Okay.
Right here I will use the resize row.
And I will put okay with this okay.
Over here.
And let me show you I will console.log requires row.
Let me perform the action into get on user.
Okay.
Let me say.
Um, Mark.
So we will.
See.
So.
Now you can say it will retrieve always the user right here based on this thing.
Okay.
Based on the method name.
Okay.
Let me summarize.
With the get handler, it will somehow Return the method name of this thing.
Okay.
And beyond that, it will retrieve all the rows.
Okay.
Because this here we're using the array.
Right.
We will set the array over here.
So it is.
And furthermore if I move the user let's say.
Let me say okay we already lost the admin and user.
So let me remove that.
With this approach we can easily.
Guess the metadata from specific method.
So I hope you understand this video and I will do the rest job in the next.
I will see you in the.