1
00:00:00,240 --> 00:00:08,160
All right, and before we start sending up JSON Web tokens, since we'll do that in the custom instance

2
00:00:08,160 --> 00:00:10,980
method, the document custom instance method.

3
00:00:11,490 --> 00:00:13,770
Why don't we set that one up first?

4
00:00:14,490 --> 00:00:22,140
Do a simple console.log online and we will add all the functionality as far as the JSON, what tokens

5
00:00:22,500 --> 00:00:23,400
are concerned?

6
00:00:23,670 --> 00:00:27,320
Again, I left the link here so I can bravely navigate here.

7
00:00:27,580 --> 00:00:34,290
You can read that documents are instances of the models, and they do have a bunch of built in since

8
00:00:34,290 --> 00:00:39,820
methods meaning in one of the previous videos, I showed you user -.so.

9
00:00:40,050 --> 00:00:42,440
So that is the built in one part.

10
00:00:42,510 --> 00:00:50,610
We can also add our own custom ones and the way that looks like we go with the schema of methods.

11
00:00:50,880 --> 00:00:52,190
So this is a key word.

12
00:00:52,210 --> 00:00:57,990
Make sure that you Typekit exactly as they show here and then the name of the function.

13
00:00:58,380 --> 00:01:02,580
So in our case, that is going to be create JWT.

14
00:01:03,000 --> 00:01:09,540
And again, what's really called that in this function, we can access our document using this.

15
00:01:10,080 --> 00:01:12,360
So we pass in the this online.

16
00:01:12,400 --> 00:01:19,470
We can access whichever property we want, and then we'll call this one actually in the controller because

17
00:01:19,470 --> 00:01:23,070
that's where we create that document, correct?

18
00:01:23,400 --> 00:01:28,950
Now keep in mind, we'll set it up in the user model, but we'll call it in the controller.

19
00:01:29,190 --> 00:01:33,750
And if you're kind of iffy on this one, don't worry, we'll get there in no time.

20
00:01:34,020 --> 00:01:38,790
So the first thing that I want to do is navigate back to my user model.

21
00:01:39,300 --> 00:01:42,480
And then since my schema name is user schema.

22
00:01:42,960 --> 00:01:47,700
We're going to go with user scheme one methods and then create JWT again.

23
00:01:47,700 --> 00:01:54,510
I'm going to use good old function keyboard and I'm going to go with console.log and enlarge the controller

24
00:01:54,810 --> 00:01:57,690
right after we create my user.

25
00:01:58,640 --> 00:01:59,480
Let's invoke it.

26
00:01:59,780 --> 00:02:04,730
Let's just see what do we have here in the console and yes, in between the videos.

27
00:02:04,760 --> 00:02:11,810
Again, I removed my good old John from the database, so I don't have to worry about that in the postman.

28
00:02:12,140 --> 00:02:20,600
So back in the user one, let's just set it up right off 30 preset rock where we're going to go with

29
00:02:20,630 --> 00:02:27,420
users scheme dot van methods and then we're going to go create jaded worker.

30
00:02:27,440 --> 00:02:30,770
So this is a function name you can call this vegan food truck.

31
00:02:30,950 --> 00:02:31,820
It doesn't really matter.

32
00:02:32,500 --> 00:02:38,270
And in my case, I'm going to go with function and set it up and in function body.

33
00:02:38,630 --> 00:02:45,800
Like I said for time being, let's simply go with Log Angus because I want to showcase that we can always

34
00:02:46,100 --> 00:02:49,630
access our document and not in the off controller.

35
00:02:49,640 --> 00:02:54,320
Like I said, once we create the user before we send it back.

36
00:02:54,640 --> 00:02:56,660
Let's go here and let's say user.

37
00:02:56,810 --> 00:03:03,470
And now we have that custom instance method so I can go and create JWT so I can invoke it.

38
00:03:03,860 --> 00:03:06,440
And now I just need to navigate back to my postman.

39
00:03:06,890 --> 00:03:12,410
And in here, let's send it one more time, and this value is going to be exactly the same.

40
00:03:12,680 --> 00:03:20,720
What I'm interested is my console, and here I can actually see that I access all the values and will

41
00:03:20,720 --> 00:03:28,940
use this when we're setting up JWT because we'll have to grab some values from our document and pass

42
00:03:28,940 --> 00:03:31,070
it in to JWT.

