1
00:00:00,330 --> 00:00:06,570
Beautiful, our user model is in place, so now, of course, let's set up the first round and steps

2
00:00:06,580 --> 00:00:07,900
are going to be following more.

3
00:00:07,920 --> 00:00:13,920
First, we want to validate and name, email and password whether, of course, the user has provided

4
00:00:13,920 --> 00:00:14,850
the correct values.

5
00:00:15,210 --> 00:00:21,330
And in this case, I'll purposely go with Mongo's option just because I want to show you how we can

6
00:00:21,330 --> 00:00:27,570
send back nice responses instead of those big objects, then we want to hash the password.

7
00:00:27,840 --> 00:00:33,840
And don't worry if this looks like gibberish to you right now, of course, I'll cover it extensively

8
00:00:34,170 --> 00:00:34,910
a little bit later.

9
00:00:35,340 --> 00:00:41,670
After that, if we're successful, if we can hash the password, if the values have been provided,

10
00:00:41,850 --> 00:00:43,560
then of course we create the user.

11
00:00:43,900 --> 00:00:50,280
And once we have the user, we want to create that token that's going to be associated with user and

12
00:00:50,280 --> 00:00:51,300
with a token.

13
00:00:51,630 --> 00:00:56,430
The user can start creating resources, which, of course, in our case is going to be jobs.

14
00:00:56,760 --> 00:01:02,600
And in order to get that token to the user, of course we will include it in our response.

15
00:01:03,390 --> 00:01:04,519
So let's get cracking.

16
00:01:05,040 --> 00:01:10,170
And of course, we're looking for controllers in this case and of course, to have the final open.

17
00:01:10,170 --> 00:01:12,420
So I'm actually in the wrong folder.

18
00:01:12,690 --> 00:01:14,520
So let me look for controllers.

19
00:01:14,730 --> 00:01:19,620
We're looking for the OTH and of course, more specifically, the registered one.

20
00:01:20,010 --> 00:01:22,080
We can start by importing the model.

21
00:01:22,500 --> 00:01:27,720
So in here I'm going to set up a user and that is going to be equal to require.

22
00:01:27,960 --> 00:01:34,350
Then we're looking at two levels up and of course I'm looking for the models and then more specifically

23
00:01:34,590 --> 00:01:35,760
a user model.

24
00:01:36,030 --> 00:01:42,120
And once I have the model before we do anything here, let's just check in the postman whether we're

25
00:01:42,120 --> 00:01:46,670
getting this silly string, because if we don't, then of course, we do need to troubleshoot.

26
00:01:47,010 --> 00:01:52,020
So as we navigate back, of course, here I have all my workspaces and I'll create a new one.

27
00:01:52,020 --> 00:01:53,310
That's not a surprise.

28
00:01:53,670 --> 00:01:57,240
I will rename it and I'll say zero six.

29
00:01:57,660 --> 00:02:01,140
And let's call this jobs API.

30
00:02:01,470 --> 00:02:03,580
Now, the URL, of course, is going to stay the same.

31
00:02:03,600 --> 00:02:05,490
Remember that global variable?

32
00:02:05,760 --> 00:02:08,400
So that saves us a little bit of time.

33
00:02:08,639 --> 00:02:10,600
And I want to go with your quest.

34
00:02:10,800 --> 00:02:13,320
This is going to be a post request.

35
00:02:13,710 --> 00:02:17,210
And here I'm going to be looking for my Yooralla, of course.

36
00:02:17,580 --> 00:02:22,700
So you are all and then remember, we're looking for auth and register.

37
00:02:22,980 --> 00:02:24,090
Hopefully that is correct.

38
00:02:24,420 --> 00:02:25,380
Let me just double check.

39
00:02:26,130 --> 00:02:29,670
So in the app Jazzier have API version one.

40
00:02:29,680 --> 00:02:33,810
So that should be still in my global variable in the past month.

41
00:02:33,990 --> 00:02:36,840
And then more specifically, off and on.

42
00:02:36,870 --> 00:02:44,580
If we take a look at the roots in here in the golf course, I have the register and like I said, both

43
00:02:44,580 --> 00:02:46,020
of them are going to be post trought.

44
00:02:46,320 --> 00:02:51,600
So why don't we start by selecting a body, then we're going farar.

45
00:02:51,840 --> 00:02:58,290
We want to go with Jason online and let's just set up the name and it's not going to be surprised if

46
00:02:58,290 --> 00:03:02,550
I'm going to go with John then as far as the email would just go with the dummy one.

47
00:03:02,760 --> 00:03:07,130
So I'm going to say John, at Gmail dot com.

48
00:03:07,350 --> 00:03:12,780
And then lastly, we want to go with password and I'm just going to stick with secret because that's

49
00:03:12,780 --> 00:03:15,050
the most simplest one in my opinion.

50
00:03:15,390 --> 00:03:19,170
So I have a name email as well as the password.

51
00:03:20,000 --> 00:03:24,020
And of course, once I send, I should get registered user.

52
00:03:24,050 --> 00:03:29,390
If you don't, then again, please troubleshoot, because otherwise anything we're about to do, it's

53
00:03:29,390 --> 00:03:36,260
not going to make sense before we move along with just save this one and I'm going to look for my jobs

54
00:03:36,620 --> 00:03:40,270
and let's just call this a register and user.

55
00:03:40,640 --> 00:03:46,730
So let's save it over here and let's try to test whether we're getting back the correct values, meaning

56
00:03:46,910 --> 00:03:49,760
whether I can access them in a rigged body.

57
00:03:50,030 --> 00:03:54,110
So change this one around where it will say or not, Jason.

58
00:03:54,260 --> 00:03:59,930
And I'm just going to pass in Aragvi then in this case, I'm just checking whether my middleware is

59
00:03:59,930 --> 00:04:00,350
correct.

60
00:04:00,620 --> 00:04:06,650
And if I can see all the three values that I'm sending from my postman, then of course we are in good

61
00:04:06,650 --> 00:04:06,960
shape.

62
00:04:07,430 --> 00:04:09,710
Now, I also want to get the status codes.

63
00:04:09,710 --> 00:04:12,200
Remember, that was the library that we used before.

64
00:04:12,440 --> 00:04:13,460
So let's go here.

65
00:04:13,460 --> 00:04:20,649
Let's say CONSED and we're looking for status code and that is coming from our library.

66
00:04:20,660 --> 00:04:28,280
The S&P status codes require Choire and we're looking for the HTP status codes.

67
00:04:28,550 --> 00:04:34,820
And then in here I want to set up the status status and of course the adjacent after that.

68
00:04:35,150 --> 00:04:40,850
And let's just go with status code and then I'll set it up as created.

69
00:04:41,130 --> 00:04:47,050
Remember, we are creating a resource, so this will send back the two hundred and one.

70
00:04:47,540 --> 00:04:53,560
And once we have all of this in place now, of course, we can create that new user.

71
00:04:53,720 --> 00:04:54,160
Correct.

72
00:04:54,500 --> 00:05:02,270
So let's go here and say const user and we'll go with a wait because of course this is a Synchronoss

73
00:05:02,510 --> 00:05:07,490
than the MONAMI user and will go create method.

74
00:05:07,790 --> 00:05:09,380
And in the create method.

75
00:05:09,380 --> 00:05:16,670
Since I want Mongo's to do all the validation, I'll simply pass in Greg body, just like we're doing

76
00:05:16,940 --> 00:05:17,720
over here.

77
00:05:17,980 --> 00:05:23,240
So now of course I can remove from my Drayson and for the time being I'll just send back the user.

78
00:05:23,480 --> 00:05:31,370
Our current code actually is a big, big mess because we're saving the passwords as they come in our

79
00:05:31,430 --> 00:05:31,830
strength.

80
00:05:31,850 --> 00:05:33,640
And that's a very, very bad practice.

81
00:05:33,890 --> 00:05:36,590
And don't worry, we will fix that a little bit later.

82
00:05:36,920 --> 00:05:39,470
For now, I just want to see whether everything works.

83
00:05:39,770 --> 00:05:44,900
And once we have back to the postman, we should be able to send the request.

84
00:05:45,260 --> 00:05:52,130
And in my response, I can say that I created a new resource in a Mongo database, since I have that

85
00:05:52,130 --> 00:05:57,980
under Corradi and then the rest of the properties that I provided in my request.

86
00:05:58,280 --> 00:06:01,910
And with this in place now, of course, we can move on to our next step.

