WEBVTT

00:00.480 --> 00:08.240
For everyone after we already create the sign.

00:09.560 --> 00:11.680
Let me remove the RC function right here.

00:14.520 --> 00:19.040
We need to generate a JSON web token after here.

00:19.080 --> 00:29.960
Right after we save the data into the database successfully, we will generate the JSON web token.

00:32.240 --> 00:34.560
Let me create a save user.

00:37.040 --> 00:39.040
And this is the promise right?

00:39.080 --> 00:48.080
For that reason you can write over here and remove something and return save user.

00:50.440 --> 00:52.120
That's the first thing.

00:52.760 --> 00:59.380
And after here we need to generate the JSON web Oh, God.

01:00.460 --> 01:03.620
Well, how to do that right now?

01:05.140 --> 01:14.500
Let's click on authentication from the security and click into the token.

01:17.100 --> 01:20.060
We need to install the package right here.

01:34.020 --> 01:40.460
After that let me show you how we can generate the JSON web token.

01:41.060 --> 01:43.780
Scroll a little bit to read the documentation.

01:43.820 --> 01:44.300
Okay.

01:44.820 --> 01:53.060
Firstly we need to import the library service into our service right here.

01:53.260 --> 01:53.740
Right.

01:55.500 --> 01:56.740
We can import over here.

02:00.570 --> 02:06.690
We need to inject JSON web token service.

02:08.450 --> 02:15.570
And after that, but before going further, let's check the terminal.

02:18.570 --> 02:27.490
If we scroll a little bit, you will see it has some error from the authentication module.

02:28.570 --> 02:40.010
The reason because right here we inject the service but we don't enable the module yet right.

02:40.530 --> 02:42.490
Open the module.

02:43.570 --> 02:47.530
Inside here we need to invoke the module.

02:50.690 --> 02:52.930
Actually we can evolve below.

02:57.390 --> 02:59.550
Because I eat orderly work.

03:00.310 --> 03:07.670
If you scroll a bit over here, you can see it also involves the stability module.

03:07.910 --> 03:16.910
And from the module we can revisit the to put the some option over here for example like market will

03:16.910 --> 03:20.230
be global okay.

03:20.230 --> 03:24.190
It later in the other module we want to use the update.

03:24.510 --> 03:33.790
It also work and global over here and secret and sign option.

03:34.630 --> 03:37.750
Let me copy everything and boost over here.

03:41.310 --> 03:46.750
And you can say with the secret will reward the some secret over here right.

03:47.270 --> 03:51.430
But I want to separate it into the environment variable.

03:52.190 --> 04:02.860
Let me show you inside are a fully unique toe boots that simulates a width and inspiration over here,

04:03.820 --> 04:05.740
and with a cigarette.

04:06.060 --> 04:19.820
You can shop some online tools with me, like a cigarette lighter, and you can show one up website

04:19.820 --> 04:23.740
and click generate and Copy everything and Buddhas over here.

04:24.340 --> 04:24.860
Okay.

04:26.700 --> 04:34.460
And how we can move inside the template module.

04:34.900 --> 04:39.420
I don't want to use something like process dot env okay.

04:39.460 --> 04:43.340
Another one that we call this is the Next.js.

04:43.780 --> 04:46.220
I will use similar.

04:49.660 --> 04:52.180
Theme with this thing.

04:53.360 --> 04:54.080
up module.

04:54.560 --> 05:03.640
Now if you remember right here is the module we will configuration with the async.

05:04.400 --> 05:06.800
And we use the use factory.

05:06.800 --> 05:09.280
And we import and inject right.

05:09.320 --> 05:12.840
I want you similar with that.

05:14.400 --> 05:21.360
Now if you face it a little bit you can see we have a register asset.

05:21.400 --> 05:21.920
Right.

05:22.680 --> 05:23.800
And let me go.

05:24.160 --> 05:28.240
And we also have a yield factory right.

05:28.280 --> 05:32.400
We also have a factory similar with this thing.

05:35.080 --> 05:37.000
Let me move this outside over here.

05:37.040 --> 05:41.560
And let me copy everything from yield boost over here.

05:42.600 --> 05:45.080
And we will invoke the config service.

05:46.080 --> 05:49.680
And let me boost everything over here.

05:50.310 --> 05:51.030
Right.

05:51.830 --> 05:53.190
And let's do that.

05:57.150 --> 06:00.230
Cigarettes will be coffee service dot get.

06:02.830 --> 06:03.670
With the.

06:07.950 --> 06:12.190
Cigarettes and sign in option also.

06:23.350 --> 06:25.110
And we need to inject.

06:30.710 --> 06:33.070
With epoch and in inject okay.

06:34.470 --> 06:35.470
Don't forget that.

06:45.110 --> 06:45.590
Okay.

06:45.910 --> 06:48.550
So that is after here.

06:48.590 --> 06:49.110
Let's check.

06:49.130 --> 06:49.810
the terminal.

06:49.850 --> 06:53.250
It's already successfully started.

06:53.370 --> 06:53.850
Right.

06:58.650 --> 06:59.610
Is that also.

06:59.610 --> 06:59.930
Wait.

06:59.970 --> 07:03.050
Let me show you how we can generate a template.

07:05.450 --> 07:06.130
Right here.

07:06.770 --> 07:08.610
Let's read the documentation.

07:15.890 --> 07:27.170
If you scroll down a bit, you will say in order to generate the template, we can size with the asynchronous

07:27.170 --> 07:27.930
operation.

07:42.730 --> 07:44.410
And we need to go to my log.

07:52.640 --> 07:53.360
We may.

07:57.640 --> 07:58.920
Save user.

07:59.520 --> 08:00.040
Dot.

08:02.080 --> 08:02.760
Underscore.

08:05.240 --> 08:05.840
Name.

08:07.080 --> 08:11.360
So user dot name and email.

08:17.920 --> 08:19.440
So we would write over here.

08:20.360 --> 08:24.680
We don't need to bother option anymore because we already configured.

08:25.920 --> 08:26.400
Okay.

08:27.640 --> 08:29.080
After here we will.

08:31.360 --> 08:32.840
Return us all.

08:33.360 --> 08:42.320
And if you would like that is the old controller is still not work because right here we already wrapped

08:42.720 --> 08:45.000
everything inside the nested object.

08:45.000 --> 08:45.480
Right?

08:48.060 --> 08:49.540
Let me test that.

08:51.020 --> 08:52.020
Here we go.

08:52.020 --> 08:52.420
Here.

08:56.540 --> 08:57.220
Is that here?

08:57.220 --> 09:04.380
I will click on send and you can see the message will be success, but it doesn't have any data.

09:05.140 --> 09:07.500
Let me show you how we can fix that.

09:07.620 --> 09:09.820
Let's open the chart from DTO.

09:12.060 --> 09:13.820
Right here we have data, right.

09:13.860 --> 09:15.260
Let me console.log for you.

09:15.300 --> 09:16.620
What is the data?

09:18.660 --> 09:21.780
And let me tell you that the error here will be the object.

09:21.820 --> 09:31.420
It will have a save user and access token because we already returned us over here, right?

09:38.300 --> 09:43.180
Now you can see it has a user and access token.

09:45.050 --> 09:47.090
We need to configure it a little bit.

09:48.570 --> 09:52.330
Now let me show you what is strategy right now.

09:52.770 --> 09:59.650
I will check if the current URL will be the authentication.

10:00.130 --> 10:00.650
Okay.

10:01.290 --> 10:06.290
We need to return the data dot user over here.

10:07.930 --> 10:08.450
Okay.

10:08.930 --> 10:11.890
And we will put the access token over here.

10:11.930 --> 10:12.410
Right.

10:12.810 --> 10:13.810
Let me show you.

10:18.050 --> 10:20.850
Firstly if you remember we have a context.

10:24.410 --> 10:27.130
I will give the context.

10:27.170 --> 10:34.810
Now switching to S3 and I will get the request right here.

10:35.890 --> 10:48.790
And if we console log request dot this will be the And right now let me just console.log the path over

10:48.790 --> 10:49.150
here.

10:53.390 --> 10:54.150
I will say.

10:57.550 --> 10:59.870
Now you can say we already got the path.

11:00.830 --> 11:04.590
Okay, let me fix that.

11:04.630 --> 11:06.910
Let me pull it over here.

11:07.230 --> 11:09.310
It has generated okay.

11:09.550 --> 11:14.350
So right here you can put directly the request from spread.

11:14.670 --> 11:15.070
Okay.

11:15.230 --> 11:20.830
So we invoke that from express okay.

11:20.830 --> 11:27.790
We will switch it into the academy and get request from spreadsheet.

11:28.190 --> 11:31.790
And this will fix that issue.

11:33.390 --> 11:35.110
Request bus over here.

11:35.150 --> 11:35.590
Okay.

11:37.350 --> 11:37.910
And.

11:41.020 --> 11:45.660
Average app is open, click on the URL.

11:46.660 --> 11:48.740
I will just ask request.

11:48.780 --> 11:49.180
Dot.

11:52.780 --> 11:53.340
Dot.

11:57.100 --> 11:57.540
Dot.

11:58.940 --> 11:59.660
In close.

12:01.780 --> 12:02.980
I will check it.

12:03.020 --> 12:06.700
Include the out okay.

12:07.260 --> 12:08.700
It will become true.

12:09.420 --> 12:14.300
So right here I will check if, uh authentication passed.

12:14.340 --> 12:18.740
I will return with the return over here.

12:19.300 --> 12:19.820
Over here.

12:20.780 --> 12:24.980
I will return the data and access token.

12:25.980 --> 12:27.940
Data access token?

12:30.900 --> 12:32.620
Right here is half.

12:34.940 --> 12:35.900
And over here.

12:40.520 --> 12:43.400
Alrighty, now we just need to ignore us.

12:47.400 --> 12:53.240
Because we don't have any way to know what exactly the data.

12:53.520 --> 12:57.360
Okay, so I think we can ignore the TypeScript.

13:01.360 --> 13:02.480
Let me show you.

13:02.960 --> 13:04.240
So here, let me sign up.

13:05.640 --> 13:06.120
Okay.

13:06.120 --> 13:10.800
We only got access token, but the data is still doesn't have right here.

13:10.800 --> 13:14.480
We need to save user.

13:15.960 --> 13:16.480
Okay.

13:23.080 --> 13:24.640
Let me say it again.

13:25.560 --> 13:26.040
Okay.

13:26.040 --> 13:28.120
We already got a message like that.

13:28.120 --> 13:31.480
And we also got the access token.

13:33.080 --> 13:33.960
Very good.

13:38.830 --> 13:44.710
Let me try to fix the script over here.

13:45.270 --> 13:50.790
It's a little bit annoying right inside.

13:50.790 --> 13:51.270
Here.

13:52.310 --> 14:01.550
Let me, uh, let me rechartering the saved user and access token.

14:03.070 --> 14:03.550
Okay.

14:03.590 --> 14:10.550
And right here I will put the say user and access token directly over here.

14:10.590 --> 14:11.030
Okay.

14:11.350 --> 14:14.390
It will fix a little bit.

14:14.390 --> 14:14.910
Right.

14:17.070 --> 14:19.150
It will doesn't have any error.

14:24.750 --> 14:25.270
Okay.

14:25.430 --> 14:26.430
This will work.

14:29.750 --> 14:33.230
And so that's for the video.

14:33.790 --> 14:36.470
And I will see you in the next one.
