WEBVTT

00:01.280 --> 00:03.000
For everyone.

00:03.440 --> 00:15.120
After we already complete the sign and sign up, we need to create the authentication rules for protected

00:15.400 --> 00:16.040
row.

00:16.080 --> 00:19.400
Okay, so let me show you.

00:19.440 --> 00:27.640
Inside the folder I will create a new file will be our rules DS.

00:29.160 --> 00:36.160
And let's go to the documentation overview and choose rules.

00:37.320 --> 00:43.000
And we need to copy the listing okay.

00:43.280 --> 00:45.080
Not try to remember this.

00:46.760 --> 00:48.000
I will boost over here.

00:48.520 --> 00:51.080
And we have our graph right.

00:55.280 --> 00:58.360
Right here what we need to do.

01:00.680 --> 01:03.530
We will switch into the request.

01:03.570 --> 01:04.090
Right?

01:04.690 --> 01:08.410
This is the acne right here.

01:08.530 --> 01:11.290
We can boost the request.

01:13.370 --> 01:15.050
From sprite.

01:15.330 --> 01:15.850
Okay.

01:17.690 --> 01:22.370
We need to extract the token from here.

01:22.410 --> 01:24.970
For example, we like the.

01:27.170 --> 01:30.890
We have a some root project route.

01:31.810 --> 01:36.050
Possible profile or something like that.

01:41.050 --> 01:43.290
Let me show you what I mean right here.

01:44.450 --> 01:50.930
Request dot headers dot authorization.

01:52.850 --> 01:53.370
Okay.

01:53.410 --> 01:57.130
And right here you can return true right now.

01:58.770 --> 02:01.290
Let me show you how we can do that.

02:01.890 --> 02:02.690
For example.

02:04.170 --> 02:09.930
In my way I will create one more controller inside the user.

02:10.570 --> 02:14.890
I will build us into the user and get profile.

02:19.290 --> 02:20.090
Users.

02:20.490 --> 02:21.130
Let us.

02:23.890 --> 02:27.530
Aggregate base and boost right here.

02:28.370 --> 02:31.570
I guess current users.

02:32.610 --> 02:38.330
And right here I will get user like this.

02:40.930 --> 02:41.610
Profile.

02:48.930 --> 02:54.130
Now I will say we already lost our data, right?

02:58.410 --> 03:05.780
But now let me show you how we can use the graph in order to use the raw lecture documentation again.

03:09.100 --> 03:12.900
We will use the right use graph.

03:13.500 --> 03:16.540
Let me invoice directly inside the class.

03:18.820 --> 03:20.460
And remove the authentication.

03:22.620 --> 03:25.780
Let me say authentication.

03:25.780 --> 03:28.660
Go directly over here.

03:30.100 --> 03:35.300
And let me get again to see what is inside console.log.

03:39.020 --> 03:41.620
So here after we said successfully.

03:44.660 --> 03:46.420
I need to copy something.

03:46.820 --> 03:48.820
And what is our getprofile.

03:48.860 --> 03:49.260
Right.

03:50.300 --> 03:52.100
So the parallel token.

03:53.780 --> 03:57.340
And I will say right here you can check.

03:57.900 --> 03:59.620
It will cost a lot.

03:59.940 --> 04:05.100
The bearer Hogan from judo, right?

04:06.180 --> 04:06.780
Right here.

04:06.820 --> 04:09.620
We need to check and follow.

04:09.660 --> 04:11.180
We will check the token.

04:11.420 --> 04:11.900
Right.

04:14.860 --> 04:20.220
With request dot header.

04:20.300 --> 04:22.580
Dot authorization.

04:27.620 --> 04:30.180
What about if we doesn't put anything?

04:30.820 --> 04:31.460
Let's say.

04:33.540 --> 04:36.700
Right here I will show no authentication.

04:38.340 --> 04:41.620
I will say we got to modify.

04:41.660 --> 04:42.140
Okay.

04:43.180 --> 04:45.180
What about if I show the token.

04:45.660 --> 04:47.700
But I don't send anything.

04:48.580 --> 04:50.380
We will also get undefined.

04:50.420 --> 04:51.900
So right here we need to check.

04:59.940 --> 05:00.700
Right here.

05:00.740 --> 05:03.220
I think we can submit directly.

05:03.220 --> 05:03.270
Like.

05:06.950 --> 05:08.590
We always do.

05:09.430 --> 05:10.030
Okay.

05:12.230 --> 05:19.390
And I will show the second one to extract the token, the JavaScript node.

05:19.990 --> 05:28.750
And we need to check if we doesn't have any token we will throw new on authorize, etc..

05:29.430 --> 05:29.950
Okay.

05:31.790 --> 05:34.910
You can boost some message over here right now.

05:34.910 --> 05:40.670
I will not do this to say what is the default.

05:42.870 --> 05:43.470
Right here.

05:43.510 --> 05:44.390
Let me test.

05:45.230 --> 05:55.510
If I don't slice the token I will say now it will send a message will be unauthorized.

05:55.750 --> 05:57.430
Please see the default message.

05:57.470 --> 05:57.750
Okay.

05:57.790 --> 06:04.160
You can customize it if you want, but right now I think this will be good with this message.

06:08.960 --> 06:11.720
After we already have a token.

06:14.000 --> 06:19.440
What we need to do, we will verify it, right?

06:20.960 --> 06:30.440
So right here we need to verify that if you remember these are the authentication service.

06:30.760 --> 06:37.640
We will inject the generate service and we will size thus right.

06:38.240 --> 06:41.240
In this case we need to do that also.

06:41.600 --> 06:44.480
This is just a class for a reason.

06:44.480 --> 06:47.960
We can inject us with a constructor.

06:48.760 --> 06:49.240
Okay.

06:50.040 --> 06:51.040
We will.

06:55.800 --> 06:58.360
Inject the service over here.

06:59.080 --> 06:59.720
Let's say.

07:05.000 --> 07:07.520
A lot of it and let it run.

07:11.120 --> 07:11.800
Right here.

07:12.240 --> 07:13.400
We got error.

07:14.120 --> 07:14.640
Right.

07:25.120 --> 07:25.880
This side.

07:28.720 --> 07:32.760
We saw result say injection.

07:35.520 --> 07:37.680
Inside user module.

07:37.720 --> 07:38.200
Why?

07:38.560 --> 07:40.080
Why the user module?

07:40.400 --> 07:43.960
Because you can see right here.

07:45.160 --> 07:52.960
In order to use the authentication rule I already invoked us inside this case.

07:52.960 --> 07:53.520
Right.

07:54.640 --> 07:57.400
So for that reason.

07:59.880 --> 08:01.400
We need to import.

08:05.410 --> 08:06.050
Also.

08:08.330 --> 08:10.690
It may not fix the issue.

08:10.730 --> 08:16.450
We will go back to where we use the authentication graph.

08:16.810 --> 08:20.530
It means that the user module we need to import the.

08:22.730 --> 08:23.450
Module.

08:33.170 --> 08:34.050
Now you can say.

08:38.450 --> 08:40.930
It will fix that issue.

08:44.330 --> 08:58.130
We can fix thus dependencies issue by import the module inside the module.

08:58.530 --> 09:03.210
We use the log right.

09:04.530 --> 09:08.380
But But I don't want that at all.

09:08.660 --> 09:10.380
You can say it later.

09:10.420 --> 09:15.220
We will have a maybe 100th module.

09:15.580 --> 09:24.820
I want one go up and boost the module one by one in every module.

09:24.860 --> 09:26.820
I will create later.

09:27.060 --> 09:27.540
Okay.

09:27.900 --> 09:31.260
I want to, but it will be global.

09:31.740 --> 09:33.460
So how we can do that.

09:33.620 --> 09:39.500
Let me remove and we will got the error right.

09:39.980 --> 09:43.580
In order to fix that issue in the best way.

09:44.300 --> 09:48.780
Let's go to the authentication module.

09:48.820 --> 09:52.620
Also right here what we need to do.

09:53.460 --> 10:04.260
You can say right now we already mark the authentication module will be global.

10:04.860 --> 10:05.340
Okay.

10:05.660 --> 10:10.740
And by the end of the day, it will import inside the app module over here.

10:12.180 --> 10:15.740
Right now we need to export.

10:18.980 --> 10:22.060
The module.

10:26.580 --> 10:27.580
But the 40.

10:32.060 --> 10:34.060
And we still have error.

10:34.620 --> 10:37.820
Secondly we will mark this thing will be global.

10:45.020 --> 10:48.380
Now you can see it already fits the issue right.

10:49.060 --> 10:50.420
Let me tell you why.

10:51.660 --> 10:57.540
Firstly the app module it will import the authentication module right.

10:58.020 --> 11:04.460
And authentication module it will export the module itself.

11:04.780 --> 11:10.190
And this will mark a Tiger team will win the global race.

11:10.230 --> 11:10.990
Module.

11:11.750 --> 11:12.030
Okay.

11:12.070 --> 11:18.230
It means entire authentication module right here will become a global module.

11:18.830 --> 11:28.790
And because this is the global module we can use the authentication module everywhere with our imports.

11:29.710 --> 11:31.390
And one more step.

11:31.670 --> 11:36.830
We already exported entire module itself.

11:37.470 --> 11:46.310
It means the module right now is already become a global also okay.

11:46.990 --> 11:47.550
That is.

11:50.470 --> 11:50.830
Right.

11:50.830 --> 11:52.950
This will fix the issue.

11:53.590 --> 11:59.590
You can say and let me go back to the go.

12:02.390 --> 12:07.470
We already got the token right and we already inject charge of it.

12:07.870 --> 12:08.430
Right here.

12:08.430 --> 12:09.190
We need to.

12:12.390 --> 12:13.430
Verify that.

12:14.950 --> 12:18.230
And right here we need to use a C function.

12:19.230 --> 12:21.150
And let me remove the boolean.

12:24.190 --> 12:24.470
Here.

12:24.470 --> 12:24.830
So.

12:29.310 --> 12:34.830
So do not verify C we need to boost the token.

12:34.990 --> 12:35.430
Right.

12:35.470 --> 12:36.150
The token.

12:37.110 --> 12:37.790
And.

12:39.830 --> 12:40.750
This is the a.

12:40.790 --> 12:41.150
Why.

12:41.310 --> 12:44.350
So for that reason we need to wrap it inside a try catch block.

12:54.470 --> 12:55.190
Over here.

12:56.790 --> 13:04.270
So let me say right here, after we already verifies the token we will copy the code.

13:04.270 --> 13:05.110
This user.

13:05.630 --> 13:06.110
Right.

13:06.790 --> 13:08.200
Let me console.log.

13:08.200 --> 13:09.160
What is right here?

13:17.480 --> 13:18.520
Let us.

13:27.120 --> 13:37.600
I will say, and you already got the decoded user over here, right?

13:40.040 --> 13:42.160
After we already got user.

13:42.800 --> 13:45.480
We will attach this.

13:51.000 --> 13:51.480
Right.

13:55.880 --> 13:56.880
Right here.

13:57.480 --> 14:02.040
We will attach this thing into the request.

14:03.800 --> 14:07.120
Request dot current user okay.

14:07.160 --> 14:10.250
We will pass it to your current user.

14:10.610 --> 14:11.330
We will.

14:12.090 --> 14:14.250
The buy long sell.

14:17.170 --> 14:17.810
Right here.

14:17.810 --> 14:19.290
I will give you the ID.

14:19.330 --> 14:22.290
We already got this user dot underscore id.

14:24.330 --> 14:32.410
Name of the user dot name and email user.

14:43.770 --> 14:43.930
ID.

14:45.130 --> 14:51.770
And of course we will fit the task group okay we will fit the task group.

14:51.770 --> 14:54.090
Let me show you how we can fix that.

14:55.930 --> 15:01.050
Firstly with the code the user right here.

15:03.770 --> 15:06.490
I will create an interface for us.

15:10.370 --> 15:10.850
Right.

15:12.250 --> 15:12.650
Um.

15:16.970 --> 15:20.330
Insert a row insert as our save folder.

15:20.970 --> 15:24.090
I will create a new file called global.

15:25.210 --> 15:25.610
Yes.

15:25.970 --> 15:28.690
This will become a global task.

15:29.890 --> 15:31.650
Right here I will provide the input file.

15:32.250 --> 15:32.610
Okay.

15:32.650 --> 15:33.490
Will be right.

15:37.970 --> 15:38.210
Here.

15:41.970 --> 15:45.770
I use my log.

15:48.650 --> 15:53.450
File name and email.

15:56.410 --> 15:57.450
I will move over here.

15:58.010 --> 16:02.810
And inside here I will pass the.

16:05.650 --> 16:09.180
R user by Why not?

16:12.380 --> 16:12.940
Please.

16:13.980 --> 16:14.980
And, uh.

16:25.620 --> 16:25.980
Um.

16:27.340 --> 16:30.660
We have a script right now.

16:39.020 --> 16:40.940
Please see the airline issue.

16:41.820 --> 16:42.180
Um.

16:44.620 --> 16:46.700
Beside this assertion is.

16:48.980 --> 16:50.780
Is unnecessary.

16:55.580 --> 16:55.900
Okay.

16:55.940 --> 16:59.300
I will ignore that also.

17:09.630 --> 17:10.350
Seated.

17:17.950 --> 17:19.070
Buddhas over here.

17:26.070 --> 17:26.630
Okay.

17:27.790 --> 17:28.470
And right here.

17:28.470 --> 17:30.350
We already are lost.

17:31.270 --> 17:32.630
And this theta thing.

17:32.630 --> 17:33.550
I will cut it.

17:33.550 --> 17:37.110
Also a user by lot.

17:39.830 --> 17:47.710
And inside the request, we need to, uh, add pass the current user into the request object.

17:49.550 --> 17:55.630
Let me show that this is the request from the spread.

17:55.630 --> 17:56.070
Right.

17:57.830 --> 18:05.470
Express.js script passed to request object.

18:05.950 --> 18:12.110
I will show some stuff like that and you can read in here.

18:18.190 --> 18:24.310
Now, now what we want is an express request object using TypeScript.

18:24.750 --> 18:31.550
You can just written and we will declare something like that.

18:31.590 --> 18:37.870
Let me copy and go to the global standards right here.

18:37.870 --> 18:45.870
We will use the current user with I user ballot okay.

18:46.230 --> 18:48.710
And right now it already fit the issue right.

18:49.390 --> 18:53.150
We already got the user ballot over here.

18:54.030 --> 18:55.430
Very very good right.

18:55.590 --> 19:05.350
That's the how we can override or actually we already extend the new property inside the library.

19:08.630 --> 19:12.480
And if we have any An error revealed rose or not?

19:12.880 --> 19:14.880
Realization is actually not so.

19:24.600 --> 19:26.600
And let me test that.

19:29.840 --> 19:30.320
Okay.

19:30.320 --> 19:32.080
It's already work.

19:34.280 --> 19:36.760
And right here we need to return.

19:40.880 --> 19:41.320
True.

19:41.760 --> 19:42.120
Okay.

19:42.120 --> 19:44.440
Actually, we already return over here.

19:44.440 --> 19:46.760
If we have any error, it will throw.

19:47.120 --> 19:47.480
Okay.

19:47.480 --> 19:57.560
For example, if I type some invalid token, say okay, it will log the error unauthorized.

19:57.600 --> 19:58.480
Very very good.

19:58.480 --> 19:58.880
Right.

20:01.440 --> 20:04.280
And say right here we already got the user.

20:04.520 --> 20:10.520
So that is not how we can create the.

20:11.840 --> 20:15.680
authentication to golf and the POI.

20:15.720 --> 20:22.120
In this video I hope you understand the global.

20:22.640 --> 20:27.360
Over here it will mark the user authority.

20:27.360 --> 20:33.760
The authentication module will become null globally.

20:34.760 --> 20:40.560
And we also export the module itself okay.

20:40.840 --> 20:49.320
Because entire thing in this module right here will be become a global.

20:49.360 --> 20:50.560
So much work.

20:50.560 --> 20:53.320
We will explore that okay.

20:53.920 --> 20:59.760
Because we want the module is now.

21:01.800 --> 21:03.080
Global also.

21:03.120 --> 21:03.520
Right.

21:03.520 --> 21:05.320
We will mark that will be global.

21:08.400 --> 21:11.880
That's for the video I will see you in the next one.
