1
00:00:08,890 --> 00:00:09,970
In this video.

2
00:00:09,970 --> 00:00:13,750
Let's get started with the low level authentication.

3
00:00:13,750 --> 00:00:15,790
So these are the steps.

4
00:00:15,880 --> 00:00:23,350
First is you are going to register a user and after that you are going to use those details to implement

5
00:00:23,350 --> 00:00:25,120
the login functionality.

6
00:00:25,120 --> 00:00:26,710
So let's get started.

7
00:00:26,890 --> 00:00:33,430
Well, I have my user model here, so let's go to the route for registration.

8
00:00:33,610 --> 00:00:37,510
So let's locate the root that is for registration.

9
00:00:37,510 --> 00:00:39,880
There is no root for registration.

10
00:00:39,880 --> 00:00:42,370
This one renders the register form.

11
00:00:42,370 --> 00:00:51,190
So let's copy this one and down here let's pass it and let's change the name here to register the user.

12
00:00:51,190 --> 00:00:54,400
So here are going to be get register form.

13
00:00:54,610 --> 00:00:56,950
Get register form.

14
00:00:57,920 --> 00:01:00,440
So let's focus on the post here.

15
00:01:00,560 --> 00:01:02,930
Here are going to be post requests.

16
00:01:03,080 --> 00:01:09,740
We are going to use Visual City Code extension called ten client to make the HTTP request than using

17
00:01:09,740 --> 00:01:10,480
postman.

18
00:01:10,490 --> 00:01:14,380
So if you don't have this extension, go ahead and install.

19
00:01:14,390 --> 00:01:19,190
It is called tender client if it's set for tender client.

20
00:01:20,400 --> 00:01:23,400
And this is what I installed.

21
00:01:23,490 --> 00:01:24,330
That is it.

22
00:01:24,330 --> 00:01:25,740
So let me collapse it.

23
00:01:25,740 --> 00:01:28,800
And now let's go ahead and create a collection.

24
00:01:28,800 --> 00:01:30,810
So let's create one collection.

25
00:01:30,810 --> 00:01:36,660
I'll click here and call this one collection and the name going to be the authentication.

26
00:01:37,380 --> 00:01:39,090
So inside the collection.

27
00:01:39,090 --> 00:01:46,530
So inside the authentication, let's create first request core register and let's provide the you are

28
00:01:46,530 --> 00:01:51,990
going to be at HTTP column four, slide four, slice looker.

29
00:01:52,700 --> 00:01:57,380
Host Cullen 3000 for a slash.

30
00:01:58,360 --> 00:02:02,530
Register and post requests and ask that.

31
00:02:02,530 --> 00:02:09,070
So let's hit send and let's see if you see that it is returning a HTML and indeed it is this one.

32
00:02:09,990 --> 00:02:13,270
This one is written in the HTML.

33
00:02:13,290 --> 00:02:16,170
So let's go ahead and register the user.

34
00:02:16,200 --> 00:02:18,870
Remember, we have the user model here.

35
00:02:18,930 --> 00:02:22,510
So we inside this function or roots.

36
00:02:22,530 --> 00:02:26,430
Let's go ahead and then register the user.

37
00:02:26,730 --> 00:02:27,960
So here we go.

38
00:02:27,990 --> 00:02:30,150
We take the user model.

39
00:02:31,780 --> 00:02:38,830
And on that we are going to use create to create a user and then you pass in the fields that you want

40
00:02:38,830 --> 00:02:39,620
to create.

41
00:02:39,640 --> 00:02:47,050
For this one, we need the full name of the user and we can get it from request, dot, body, dot,

42
00:02:47,050 --> 00:02:52,820
food name and the next property is going to be Let's have a look.

43
00:02:52,840 --> 00:02:55,690
User name, full name, password and image.

44
00:02:55,690 --> 00:02:57,490
So here we go.

45
00:02:57,490 --> 00:03:02,830
After full name, you're going to provide the user name and the same thing.

46
00:03:02,830 --> 00:03:05,200
We can get it from rec dot body.

47
00:03:09,200 --> 00:03:10,970
Dot username.

48
00:03:11,450 --> 00:03:20,220
And lastly, I'm going to be the password also from the rec dot buddy dot password.

49
00:03:20,240 --> 00:03:23,750
But I thought we can structure it from the regular body.

50
00:03:23,750 --> 00:03:25,730
But let's make it as simple as this.

51
00:03:25,910 --> 00:03:30,050
And for the image, we are going to use the default image here.

52
00:03:30,050 --> 00:03:33,560
So we don't need to provide them when you are creating it.

53
00:03:33,590 --> 00:03:35,780
So now this is our create function.

54
00:03:36,550 --> 00:03:39,740
So here, let's handle the premise, then.

55
00:03:39,760 --> 00:03:40,630
Here we go.

56
00:03:40,660 --> 00:03:42,100
We have the user.

57
00:03:42,520 --> 00:03:50,380
And if everything goes well, let's go ahead and then console.log the user.

58
00:03:51,840 --> 00:03:56,850
Is that if something goes wrong let's handle it as that.

59
00:03:56,850 --> 00:04:00,660
And make use of error and console.log.

60
00:04:00,660 --> 00:04:01,350
The.

61
00:04:03,130 --> 00:04:03,750
Error.

62
00:04:04,020 --> 00:04:09,360
Well, for this one we can make use of async await, but let's make it pretty simple here.

63
00:04:09,370 --> 00:04:12,100
So now we have the root.

64
00:04:12,100 --> 00:04:13,840
So let's go ahead and register.

65
00:04:13,840 --> 00:04:18,220
So let's open the ten dot lines and now click collection.

66
00:04:18,220 --> 00:04:21,040
And inside we have this request.

67
00:04:21,040 --> 00:04:23,140
So let's pass in the payload.

68
00:04:23,140 --> 00:04:27,370
So click on body and click on JSON and here we go.

69
00:04:27,370 --> 00:04:29,530
So let's provide the first.

70
00:04:29,530 --> 00:04:32,110
The first one is full name.

71
00:04:33,350 --> 00:04:36,110
And let's call this one as John.

72
00:04:37,230 --> 00:04:40,920
And the person user name.

73
00:04:44,150 --> 00:04:47,630
I'll call this one as Johnny.

74
00:04:48,570 --> 00:04:53,080
I is the person with the name and then the password.

75
00:04:54,030 --> 00:04:56,770
Is going to be one, two, three, four, five.

76
00:04:56,790 --> 00:04:58,530
So now let's hit st.

77
00:04:58,560 --> 00:05:02,760
Now let's have a look where we are not returning any response.

78
00:05:02,760 --> 00:05:06,930
But if you check our terminal, let's check our terminal and see.

79
00:05:06,930 --> 00:05:12,060
So let's open our terminal and let's see that it has been created.

80
00:05:12,090 --> 00:05:18,030
Now click here and I can see that we have the user being created here.

81
00:05:18,060 --> 00:05:23,310
Now we have the user with user name and then the password.

82
00:05:23,310 --> 00:05:30,300
But before we continue, if we want to visualize this document inside our dashboard, we can use what

83
00:05:30,300 --> 00:05:32,460
is called the compass.

84
00:05:32,460 --> 00:05:42,480
So if I refresh it and inside the school and in that I have visa collection and this is a user I created

85
00:05:42,480 --> 00:05:48,150
and better so we can visualize the same code inside our Visual City code.

86
00:05:48,150 --> 00:05:49,260
And this one too.

87
00:05:49,290 --> 00:05:53,580
We've talked about it where we use MongoDB extension to visualize.

88
00:05:53,580 --> 00:05:57,210
So click on this one and then reconnect or connect.

89
00:05:57,240 --> 00:06:04,440
And here we can see our database and collections inside Visual Studio code, how awesome it is.

90
00:06:04,440 --> 00:06:08,910
And here if I open this cool database, I have to use this.

91
00:06:08,910 --> 00:06:16,650
And in there I have one document which is this user and the same has to be see inside Compass.

92
00:06:16,650 --> 00:06:22,860
So I'm going to use this extension to visualize my database, what is going on or better so you can

93
00:06:22,860 --> 00:06:25,140
use what is called the compass.

94
00:06:25,140 --> 00:06:29,790
So now we are ready to go to get started with the log in system.

95
00:06:29,820 --> 00:06:30,930
Then this video.

96
00:06:30,930 --> 00:06:34,200
Let's go ahead and implement the login functionality.

