1
00:00:00,150 --> 00:00:00,600
Beautiful.

2
00:00:01,110 --> 00:00:06,900
And once we have the token in place, I said now navigate to all the controller.

3
00:00:07,500 --> 00:00:10,380
We're pretty much done with the register.

4
00:00:11,100 --> 00:00:13,470
Pretty sure we're not going to come back here.

5
00:00:14,040 --> 00:00:15,270
So let me scroll down.

6
00:00:15,270 --> 00:00:18,180
We verify the email that looks about right.

7
00:00:18,870 --> 00:00:23,430
I want to close the read me for now because this pretty much new stuff.

8
00:00:23,940 --> 00:00:25,980
So I think it's better.

9
00:00:25,980 --> 00:00:30,990
If we do together and learn JWT, we will store it down here.

10
00:00:31,080 --> 00:00:32,220
So we want to open.

11
00:00:33,110 --> 00:00:41,970
And then when it comes to a log in, once I get my token user, we'll have to set up more functionality.

12
00:00:42,830 --> 00:00:44,170
So this is the token user.

13
00:00:44,180 --> 00:00:47,360
This is the one that I can safely bash.

14
00:00:47,660 --> 00:00:48,110
Correct.

15
00:00:48,740 --> 00:00:50,590
And here's what I want to do right now.

16
00:00:50,600 --> 00:00:58,640
First, I will comment about the attach cookies to response because we'll pass in more data and I want

17
00:00:58,640 --> 00:00:59,990
to do that in a separate video.

18
00:01:00,380 --> 00:01:02,660
So I want to split it up as much as possible.

19
00:01:03,580 --> 00:01:05,920
So that way, we have less confusion.

20
00:01:06,460 --> 00:01:10,480
And once I get my user wants, I'm successful.

21
00:01:11,460 --> 00:01:13,620
I actually want to do two things.

22
00:01:13,710 --> 00:01:18,810
First, I want to check whether there is an existing token for two years.

23
00:01:19,350 --> 00:01:20,730
But we'll do that later.

24
00:01:21,030 --> 00:01:23,490
So for now, I'll just say check.

25
00:01:24,290 --> 00:01:30,060
For existing doctrine, and I'll showcase why that is important.

26
00:01:30,080 --> 00:01:31,370
So for now, don't worry about it.

27
00:01:32,030 --> 00:01:37,430
But before we go any further above it, I just say create.

28
00:01:38,460 --> 00:01:44,450
Refresh and token now I'll start with just let.

29
00:01:44,910 --> 00:01:46,590
And it's going to be an empty string.

30
00:01:47,070 --> 00:01:52,570
And the reason for that, because Brennan will be checking for that existing token will set the value.

31
00:01:52,630 --> 00:01:58,260
And again, if that doesn't make sense right now, you'll see that once we check for existing token.

32
00:01:58,530 --> 00:01:59,970
So for now, here's what I want to do.

33
00:01:59,970 --> 00:02:09,150
I want to go with let 'em say refresh token, refresh token, and that will be equal to an empty string.

34
00:02:09,610 --> 00:02:09,960
Correct.

35
00:02:11,130 --> 00:02:14,670
Like I said, there's going to be functionality to check for existing token.

36
00:02:15,210 --> 00:02:16,680
Not going to worry about it right now.

37
00:02:17,250 --> 00:02:24,450
And I want to create that token now since users logging in and I want to set up two cookies.

38
00:02:24,840 --> 00:02:28,170
I want to have the access one and the refresh one.

39
00:02:28,350 --> 00:02:30,810
And essentially, I want to create that token.

40
00:02:31,170 --> 00:02:35,250
I want to create that token model and tie it to a user.

41
00:02:35,700 --> 00:02:36,690
Sounds about right.

42
00:02:37,230 --> 00:02:45,260
So let's start here with a refresh token and we'll use the crypto one same like we did with verification.

43
00:02:45,270 --> 00:02:52,440
We'll go with random bytes with 40 and we'll invoke to string and will pass in the Hex run.

44
00:02:52,470 --> 00:02:55,200
I want to set up the user agent and IP.

45
00:02:55,860 --> 00:02:58,800
And again, maybe this is a repetition.

46
00:02:58,800 --> 00:03:07,530
But what I'm trying to do right now is get all these fields here because I'm assuming that the user

47
00:03:07,530 --> 00:03:12,270
doesn't have already a token, which is something that we will cover later.

48
00:03:12,750 --> 00:03:18,870
So for now, I'm just assuming that user is logging in for the first time and I right away, I want

49
00:03:18,870 --> 00:03:21,630
to attach this token to a user.

50
00:03:21,900 --> 00:03:24,660
And then one by one, I want to set up the IP.

51
00:03:24,660 --> 00:03:27,840
User agent is valid and yaari area.

52
00:03:28,350 --> 00:03:33,390
So back in the off controller, we have the first one refresh token now.

53
00:03:33,960 --> 00:03:36,870
Well, now let's take a look at how we can access user agent.

54
00:03:37,200 --> 00:03:42,330
So here let's set up user agent property that is equal to your request.

55
00:03:43,270 --> 00:03:49,060
At first and the way reactions averages go it user and then urgent.

56
00:03:49,360 --> 00:03:53,460
So this is another way I can access something in horror.

57
00:03:53,530 --> 00:03:57,470
Remember the previous one I showed you in the register?

58
00:03:58,000 --> 00:03:58,720
It was like this.

59
00:03:59,230 --> 00:04:01,840
It was get and then whatever the name.

60
00:04:02,410 --> 00:04:06,700
Now also an option is this one where you go with rec header.

61
00:04:06,720 --> 00:04:08,990
So we're still looking in the request.

62
00:04:09,010 --> 00:04:10,030
We're still looking at.

63
00:04:10,540 --> 00:04:12,760
And I'm more specifically looking for this one.

64
00:04:12,850 --> 00:04:16,300
The user agent, then I also want to get the IP address.

65
00:04:16,959 --> 00:04:19,240
So say your IP is equal to Eric.

66
00:04:19,600 --> 00:04:22,089
And you guessed it, the property is IP.

67
00:04:22,520 --> 00:04:26,750
And now it's create a object with all these three properties.

68
00:04:27,340 --> 00:04:30,250
In this case, I'm going to call this user OK.

69
00:04:30,790 --> 00:04:32,830
Not as equal to refresh, though.

70
00:04:33,610 --> 00:04:41,490
Brian, I want to set up the IP address user agent and then remember, the is valid is there by default.

71
00:04:41,680 --> 00:04:47,440
So I don't need to do anything, but I do need to pass in the user correct because I will be required.

72
00:04:47,800 --> 00:04:48,520
So here we go.

73
00:04:48,520 --> 00:04:51,220
With user marriage equal to what?

74
00:04:51,730 --> 00:04:56,370
Well, if I scroll up, whereas my user, where is the eddy?

75
00:04:56,590 --> 00:04:58,230
It is, underscore Eddy.

76
00:04:58,450 --> 00:05:04,810
So go here with user and an underscore and I.D. So I have my token.

77
00:05:05,140 --> 00:05:07,150
Now I need to get the model correct.

78
00:05:07,570 --> 00:05:10,720
So let's copy and paste looking for the token here?

79
00:05:11,650 --> 00:05:12,110
Duncan.

80
00:05:12,850 --> 00:05:17,890
And that is coming from the models, of course, get the token.

81
00:05:18,670 --> 00:05:23,350
And in order to create one, we just need to invoke Duncan, not create.

82
00:05:24,070 --> 00:05:27,310
So let's keep scrolling where we have the.

83
00:05:28,300 --> 00:05:29,080
User token.

84
00:05:30,200 --> 00:05:39,050
And Lemon, here, I just go with a weight token that create a let's pass in the user token.

85
00:05:39,410 --> 00:05:46,460
The object we just created and like I said, we all deal with cookies eventually, meaning one of the

86
00:05:46,460 --> 00:05:47,180
following videos.

87
00:05:47,630 --> 00:05:51,410
For now, I just want to showcase that we're getting back the token user.

88
00:05:51,950 --> 00:05:54,730
But I also want to showcase the token.

89
00:05:55,130 --> 00:05:56,240
So token here.

90
00:05:56,420 --> 00:05:57,560
Now this is temporary.

91
00:05:57,740 --> 00:06:02,090
Actually, we're not going to send it back, but just to showcase that we actually get it there.

92
00:06:02,120 --> 00:06:07,640
I'll show you that in the post, man, as well as the database.

93
00:06:08,120 --> 00:06:09,590
So let me say this now.

94
00:06:09,680 --> 00:06:15,180
And like I said, the good news is that we don't need to do these deletions and registering and all

95
00:06:15,200 --> 00:06:18,230
that we can simply go back to a post, man.

96
00:06:18,860 --> 00:06:20,450
I'm going to go to it, John.

97
00:06:20,900 --> 00:06:24,140
And if everything is correct, I should.

98
00:06:24,590 --> 00:06:26,930
And path is valid is required.

99
00:06:27,680 --> 00:06:28,130
Okay.

100
00:06:28,130 --> 00:06:28,670
Let's see.

101
00:06:28,670 --> 00:06:29,090
Let's see.

102
00:06:29,090 --> 00:06:29,720
Let's see.

103
00:06:30,910 --> 00:06:32,170
I set it up as default.

104
00:06:34,480 --> 00:06:35,440
Well, we are required.

105
00:06:35,860 --> 00:06:42,850
And my apologies, I wasn't here with the required true, what I should have done is set up as default

106
00:06:43,120 --> 00:06:44,770
and true, and I believe that.

107
00:06:45,830 --> 00:06:52,040
I properly showcased that in the read me, my apologies shown here, I said the default true.

108
00:06:52,190 --> 00:06:54,110
And then I actually set it up as required.

109
00:06:54,830 --> 00:06:57,830
My deepest, deepest apologies for this silly bug.

110
00:06:58,130 --> 00:06:59,930
Now let's try to do that one more time.

111
00:07:00,880 --> 00:07:01,730
I'm going to go back.

112
00:07:02,570 --> 00:07:05,240
And we'll send it and now check it out.

113
00:07:05,810 --> 00:07:08,960
So not only I'm getting back the user.

114
00:07:09,930 --> 00:07:11,490
I also get the token.

115
00:07:12,090 --> 00:07:16,740
So that's the token that is tied to a user with a refreshed token.

116
00:07:17,710 --> 00:07:22,540
With IP, with user agent is valid and all of that cool stuff.

117
00:07:22,960 --> 00:07:29,910
So now what we can do, we can take a look how we can set up cookies when we are thatching cookies to

118
00:07:29,930 --> 00:07:30,730
a response.

