WEBVTT

00:00.760 --> 00:02.360
Hi everyone.

00:02.400 --> 00:04.080
After we already.

00:06.200 --> 00:11.600
Ask the rose property into the user collection.

00:13.560 --> 00:20.360
We need to do the authorization right now before writing the code.

00:20.400 --> 00:24.160
Let me show you what the idea first.

00:24.200 --> 00:33.520
Okay, I want to show you what we need to do for our polarization in laser inside the ground right here.

00:33.840 --> 00:37.880
I will use one more goal will be authorization draw.

00:38.120 --> 00:38.520
Okay.

00:38.560 --> 00:39.640
For example, like that.

00:47.600 --> 00:48.200
And?

00:51.480 --> 00:53.320
Actually, this is the ruler.

00:53.360 --> 00:53.920
Okay.

00:53.960 --> 00:55.320
It's much better.

00:56.440 --> 01:07.230
And furthermore, in order to create a new new user, I want only the admin can create the new user.

01:07.550 --> 01:14.790
Okay, so for that reason I want to boost something like this to be row with admin.

01:15.710 --> 01:17.030
Okay something like that.

01:18.110 --> 01:20.630
And inside the file own method.

01:20.790 --> 01:27.870
Also I want only the admin can find all users.

01:29.670 --> 01:34.150
And here will be the same with the admin.

01:34.710 --> 01:35.990
Or actually.

01:38.750 --> 01:45.150
I want the admin and user can also find the user.

01:45.590 --> 01:45.990
Okay.

01:46.030 --> 02:01.630
But the admin right here can find any user if that means one and the users can only access into belong

02:01.630 --> 02:02.230
that user.

02:02.270 --> 02:02.550
Okay.

02:02.590 --> 02:12.460
For example right here we will add, for example, we have a user one hot and one we have user to have

02:12.460 --> 02:13.940
a little okay.

02:14.060 --> 02:21.260
The admin can find the user one with the ID right here, or user two if that means one okay.

02:21.660 --> 02:26.980
But the normal user for example, when I logged in I logged in with the user one.

02:27.020 --> 02:30.300
It means I only can access to my profile.

02:30.660 --> 02:31.140
Okay.

02:31.340 --> 02:35.340
I cannot be able to access it to the another profile.

02:35.980 --> 02:41.380
That's what I want to build the version for the users okay.

02:41.700 --> 02:44.620
And this will be the same with update okay.

02:44.660 --> 02:50.380
I want the admin can update any account okay.

02:50.620 --> 02:55.220
But user can only update um on account.

02:56.220 --> 02:56.780
Right.

02:57.060 --> 02:59.300
And the list will be also okay.

02:59.340 --> 03:02.620
That's what we want right now.

03:02.660 --> 03:06.180
Let me show you How to do last.

03:13.140 --> 03:23.220
Now, right here inside the course, I will create one more row with authorization graph.

03:23.980 --> 03:24.420
Sorry.

03:24.580 --> 03:28.660
Row, row plus these.

03:29.940 --> 03:32.580
And I need to copy this.

03:33.660 --> 03:34.220
Right.

03:37.700 --> 03:40.780
Inside the for loop.

03:40.860 --> 03:41.340
Sorry.

03:41.820 --> 03:47.900
Is that a overview of GA and copy everything.

03:50.020 --> 03:54.660
And change row row row and row.

03:54.660 --> 03:58.340
Here let's replace with a retro okay.

03:59.340 --> 04:03.580
And we already have a row GA.

04:04.140 --> 04:07.730
So how about The custom decorator.

04:08.410 --> 04:09.410
Let me show you.

04:10.930 --> 04:15.450
If you click inside the security, click on authorization.

04:16.690 --> 04:18.490
We will scroll a little bit.

04:18.690 --> 04:27.050
Give you say right here we will define a new decorator with the row okay.

04:27.090 --> 04:34.490
We will use we will use the set metadata from.

04:34.490 --> 04:35.130
Net yes.

04:35.730 --> 04:38.970
And we will put a key a value okay.

04:39.530 --> 04:44.290
Right now let's go with me and I will explain that for you.

04:44.330 --> 04:47.650
What exactly about we set metadata.

04:48.570 --> 04:50.770
So now let's create the decorator.

04:53.650 --> 04:55.370
Row decorator.

04:56.290 --> 04:56.730
Yes.

04:57.170 --> 05:02.650
And I will copy everything over here so that we can remove the row.

05:05.010 --> 05:05.450
Right here.

05:05.450 --> 05:08.200
Let's replace it with only screen.

05:13.800 --> 05:14.280
And.

05:17.680 --> 05:20.760
Obtain the screen right here is not good.

05:23.000 --> 05:31.840
If you are going to keep my USA, does the rotor here only have user and admin software inside the global?

05:32.240 --> 05:34.160
I will define the new in the file.

05:34.680 --> 05:36.480
I row.

05:38.320 --> 05:41.760
I'm ready for the pass.

05:41.800 --> 05:44.400
Okay we will admin.

05:49.960 --> 05:50.480
Okay.

05:50.520 --> 05:51.080
Like this.

05:51.840 --> 06:00.000
And I will use that directly into the user schema over here.

06:01.080 --> 06:04.400
It will be totally the same okay.

06:04.440 --> 06:13.150
And right now inside the decorator I click give you a row over here with a row.

06:13.150 --> 06:13.590
Okay.

06:13.630 --> 06:17.150
We will divide the rows like this.

06:17.670 --> 06:19.910
It means it will row right here.

06:19.950 --> 06:20.270
Okay.

06:20.310 --> 06:21.150
Very easy.

06:21.590 --> 06:28.030
So after we already got the rows right here, let's replace this.

06:29.190 --> 06:30.070
He brought us.

06:32.310 --> 06:33.230
He brought us.

06:37.710 --> 06:40.710
Okay, this will be work.

06:41.230 --> 06:45.270
And let me explain for you what exactly about set metadata?

06:45.630 --> 06:45.910
Okay.

06:45.950 --> 06:49.750
The metadata is decorator.

06:50.150 --> 06:50.630
Okay.

06:50.950 --> 06:54.070
It already written by Next.js.

06:55.630 --> 06:56.870
So what?

06:57.310 --> 07:01.150
What is made row here?

07:01.430 --> 07:09.150
First of all, inside the controller we will use decorator right here in the method.

07:09.190 --> 07:09.790
Okay.

07:09.830 --> 07:10.590
It may.

07:11.510 --> 07:21.630
It will somehow generate no metadata for specific method.

07:22.030 --> 07:22.550
Okay.

07:23.830 --> 07:25.190
Let me show you what I mean.

07:25.230 --> 07:29.310
You can see the result of the segment and that will be somehow like this.

07:29.670 --> 07:31.030
Okay with me.

07:31.430 --> 07:35.830
If you say right here the case.

07:37.910 --> 07:42.870
Right here, it will become somehow like the row case, right?

07:43.190 --> 07:51.710
It will become somehow this rows and right here it will boost the method possible like five one.

07:52.270 --> 07:59.470
And right here it will boost the row like mean okay.

08:03.070 --> 08:05.230
And user okay.

08:05.270 --> 08:13.220
And maybe in the create method it will create only that mean okay it will somehow create something like

08:13.220 --> 08:13.500
this.

08:14.460 --> 08:14.900
Okay.

08:14.940 --> 08:15.980
This is the.

08:18.940 --> 08:19.620
Image.

08:19.660 --> 08:21.020
With the set metadata.

08:21.020 --> 08:28.540
It will create the metadata for specific methods.

08:29.260 --> 08:29.700
Okay.

08:29.740 --> 08:32.500
And it only exists in the runtime.

08:33.820 --> 08:34.180
Okay.

08:34.220 --> 08:42.300
When we bootstrap or when we start the application, it will create the structure like this for you.

08:42.660 --> 08:43.180
Okay.

08:43.460 --> 08:45.620
That's about metadata.

08:46.700 --> 08:49.780
And for that reason we can retrieve that okay.

08:50.020 --> 08:56.500
Of course when we set that we can achieve that using this split.

08:56.540 --> 08:57.020
Why.

08:59.500 --> 09:00.420
Let me say.

09:19.850 --> 09:22.450
Let me find somewhere.

09:27.890 --> 09:29.610
We can retrieve that.

09:30.330 --> 09:30.810
Here.

09:32.170 --> 09:32.690
Okay.

09:32.690 --> 09:33.930
We can use this.

09:33.970 --> 09:34.410
Why?

10:02.610 --> 10:09.730
We can find us in the execution context and click into the reflection and metadata.

10:10.130 --> 10:11.170
Okay, you can see.

10:13.330 --> 10:17.200
Right here we can search like that.

10:17.240 --> 10:25.920
And it also get us, you say this dot reflector and we will pass the, uh, the case.

10:26.200 --> 10:26.680
Okay.

10:28.760 --> 10:35.240
And we need to pass the context of the handler.

10:35.280 --> 10:35.640
Okay.

10:35.680 --> 10:39.240
This will be return for use the method okay.

10:39.600 --> 10:43.240
It will return for you the method name okay.

10:43.280 --> 10:46.080
For example like firewall okay.

10:46.120 --> 10:47.440
Or something like that.

10:49.320 --> 10:53.640
So that's with this way we can retrieve that.

10:54.160 --> 11:03.120
Let me show you inside the controller we need to inject the reflector.

11:03.400 --> 11:04.000
Right.

11:07.080 --> 11:10.080
Right here we can invoke that.

11:13.520 --> 11:14.640
Inside here let.

11:16.670 --> 11:19.150
Private flat.

11:30.030 --> 11:31.070
And let's say.

11:37.270 --> 11:40.990
And after that, let me show you.

11:41.870 --> 11:44.910
I will copy paste this line of code.

11:45.310 --> 11:46.510
I'm not remember.

11:46.550 --> 11:47.030
Okay.

11:47.830 --> 11:52.830
Right here I will use the resize row.

11:55.550 --> 11:58.870
And I will put okay with this okay.

11:58.910 --> 11:59.470
Over here.

12:04.670 --> 12:09.030
And let me show you I will console.log requires row.

12:17.830 --> 12:24.510
Let me perform the action into get on user.

12:24.870 --> 12:25.350
Okay.

12:32.190 --> 12:32.870
Let me say.

12:35.590 --> 12:37.110
Um, Mark.

12:37.110 --> 12:39.150
So we will.

12:43.990 --> 12:44.750
See.

12:56.830 --> 12:57.390
So.

12:59.550 --> 13:08.510
Now you can say it will retrieve always the user right here based on this thing.

13:08.750 --> 13:09.230
Okay.

13:09.270 --> 13:10.510
Based on the method name.

13:11.470 --> 13:11.870
Okay.

13:11.870 --> 13:12.870
Let me summarize.

13:13.790 --> 13:21.300
With the get handler, it will somehow Return the method name of this thing.

13:21.340 --> 13:21.860
Okay.

13:22.660 --> 13:26.860
And beyond that, it will retrieve all the rows.

13:27.260 --> 13:27.780
Okay.

13:28.380 --> 13:33.020
Because this here we're using the array.

13:33.060 --> 13:33.540
Right.

13:34.060 --> 13:36.700
We will set the array over here.

13:39.140 --> 13:39.700
So it is.

13:40.580 --> 13:44.020
And furthermore if I move the user let's say.

13:52.020 --> 13:57.340
Let me say okay we already lost the admin and user.

13:57.820 --> 13:59.140
So let me remove that.

14:02.300 --> 14:04.900
With this approach we can easily.

14:07.260 --> 14:12.380
Guess the metadata from specific method.

14:12.540 --> 14:19.060
So I hope you understand this video and I will do the rest job in the next.

14:19.380 --> 14:20.260
I will see you in the.
