1
00:00:00,150 --> 00:00:01,080
That wasn't nice and easy.

2
00:00:01,380 --> 00:00:09,810
And once we have our say in place now, it's finally hash the password and a side note in between the

3
00:00:09,810 --> 00:00:10,180
videos.

4
00:00:10,500 --> 00:00:19,830
I did remove my John user from database, so my postman, I'll be able to reuse of the values and essentially

5
00:00:19,830 --> 00:00:21,060
the steps are falling.

6
00:00:21,270 --> 00:00:23,940
First, we want to start with Uninstall.

7
00:00:24,300 --> 00:00:32,400
So let me stop the server and discuss clearly console and I sent out a nice, nifty trick is going with

8
00:00:32,700 --> 00:00:35,940
control and out, which pretty much moves it.

9
00:00:36,210 --> 00:00:41,820
So for many years, I've been typing clear, but you can actually do it with control and health.

10
00:00:42,690 --> 00:00:43,980
And of course not is on a Mac.

11
00:00:43,980 --> 00:00:50,280
But you can go to my Twitter and you can find one of the tweets where you'll find the options for Windows

12
00:00:50,280 --> 00:00:50,730
as well.

13
00:00:51,090 --> 00:00:54,750
And we want to go with npm install be crypt.

14
00:00:55,110 --> 00:01:01,920
So let me grab my first line of code copy and paste, and then let's star up our server.

15
00:01:02,130 --> 00:01:09,480
And once our server is up and running, it actually looks like I forgot to add import the script in

16
00:01:09,480 --> 00:01:10,350
the user model.

17
00:01:10,650 --> 00:01:14,310
Now it is kind of self-explanatory, but let me just add it over here.

18
00:01:14,310 --> 00:01:20,820
So let me go with b script and I'm going to call the actual variable B script.

19
00:01:21,180 --> 00:01:24,210
But remember that that is coming from the library.

20
00:01:24,210 --> 00:01:25,500
So Bikram jazz.

21
00:01:25,890 --> 00:01:32,130
And let's add here import, import in and use the online model.

22
00:01:32,520 --> 00:01:38,760
Let's say that I want and actually go to the user model and look for the beta version.

23
00:01:38,910 --> 00:01:41,850
So we're looking for already package.

24
00:01:42,490 --> 00:01:45,840
And like I said, I'm going to call this be just a little bit faster.

25
00:01:45,840 --> 00:01:47,940
But keep in mind where it's coming from.

26
00:01:47,950 --> 00:01:56,010
So be crypt jazz and the line where we want to keep on scrolling, keep on scrolling and in our preset

27
00:01:56,010 --> 00:01:58,140
hook, we want to set up the functionality.

28
00:01:58,470 --> 00:02:00,520
Now how is the functionality going to look like?

29
00:02:00,540 --> 00:02:02,500
Well, we'll have a few functions.

30
00:02:02,520 --> 00:02:03,060
First of all.

31
00:02:04,250 --> 00:02:09,889
There's going to be a hash function where we pass in the password as well as the salt.

32
00:02:10,130 --> 00:02:14,230
But before we can do that, we'll have to generate the salt now.

33
00:02:14,240 --> 00:02:15,590
Looks like I have a typo here.

34
00:02:15,950 --> 00:02:17,630
So it should be James salt.

35
00:02:18,020 --> 00:02:19,640
Both of them are going to be a synchronous.

36
00:02:19,940 --> 00:02:24,530
And you can think of this one as creating extra characters.

37
00:02:24,840 --> 00:02:26,660
And these are just ROMs that you present.

38
00:02:26,930 --> 00:02:28,770
Keep in mind that the more iPhones you have.

39
00:02:28,790 --> 00:02:33,110
Yes, it's going to be more secure, but it will also take longer time.

40
00:02:33,500 --> 00:02:39,110
And I believe 10 is a default and essentially 10 rounds is solid approach.

41
00:02:39,500 --> 00:02:46,190
So let's navigate back to our user and then right away, let's set this up as a sync function.

42
00:02:46,730 --> 00:02:47,930
And what do we want to do?

43
00:02:48,110 --> 00:02:49,880
Well, we want to generate that salt.

44
00:02:49,970 --> 00:02:50,420
Correct.

45
00:02:50,750 --> 00:02:57,260
So we go here with Konst salt is equal to and that a weight of the variable name.

46
00:02:58,040 --> 00:03:00,410
Gosh, that is bigger than that.

47
00:03:00,710 --> 00:03:06,610
And then I'm looking for gen salt and then we want to pass in the realms, which is going to be 10.

48
00:03:07,010 --> 00:03:08,310
And what is the next step?

49
00:03:08,350 --> 00:03:16,370
Well, then I want to set my password, the one that I will have in the document equal to something.

50
00:03:16,520 --> 00:03:17,570
Now what is that something?

51
00:03:17,930 --> 00:03:22,910
Well, that is the value that I'm going to get back from the hash one where again, I'll pass in the

52
00:03:22,910 --> 00:03:31,430
password that is provided by the user and I'll set up the document password equal to a hash value.

53
00:03:32,210 --> 00:03:33,320
Hopefully, that makes sense.

54
00:03:33,650 --> 00:03:35,600
So let's go over here with this dot password.

55
00:03:35,610 --> 00:03:40,820
Remember, we're just logged in a previous video, so we know that we can access it and we're going

56
00:03:40,820 --> 00:03:45,650
to go with await when I can script that.

57
00:03:45,920 --> 00:03:51,170
And now we're looking for to hash and instead of the hash, we're passing this dot password.

58
00:03:51,680 --> 00:03:58,520
So again, whatever the user is providing, I'm on the second value is going to be the salt.

59
00:03:58,970 --> 00:04:02,660
And once we set this one up, let's try it one more time and a postman.

60
00:04:02,990 --> 00:04:10,970
And as a result, we should see our password nicely hashed when we stored in our database.

61
00:04:11,120 --> 00:04:15,470
So let me navigate to my post, man, and let me send it one more time.

62
00:04:15,980 --> 00:04:20,029
And what do you know her name, email and look at the password?

63
00:04:20,420 --> 00:04:26,090
Now, keep in mind that, of course, we're not going to be sending back this password to a frontend.

64
00:04:26,780 --> 00:04:28,160
So this is just temporary.

65
00:04:28,460 --> 00:04:31,340
Just so we can see whether our functionality works.

66
00:04:31,700 --> 00:04:32,120
Yes.

67
00:04:32,360 --> 00:04:38,540
Eventually, we'll actually remove the password from our response because it's not a good approach to

68
00:04:38,750 --> 00:04:41,300
send those passwords in the first place.

69
00:04:41,690 --> 00:04:48,290
And with this in place now, we can start focusing on setting up the JSON web token.

