1
00:00:00,390 --> 00:00:06,540
Beautiful, and once we have the send verification email functionality in place.

2
00:00:07,080 --> 00:00:11,250
Now let me cover some gotchas that you need to be aware of.

3
00:00:11,910 --> 00:00:19,500
And first, let me just start by showing you at least how in react I set up the functionality again.

4
00:00:19,980 --> 00:00:24,240
If you're using different front end, it is going to change.

5
00:00:24,240 --> 00:00:29,350
But in my case, I did set up following page.

6
00:00:29,820 --> 00:00:32,280
So I'm using React.

7
00:00:32,700 --> 00:00:39,860
I have multiple pages, I'm using React router and this is the page, so I user and then verify email.

8
00:00:39,870 --> 00:00:45,120
That's why initially I got four or four pictures and here I messed it up.

9
00:00:45,420 --> 00:00:50,940
I said the origin, which was localhost three thousand new user and I went with token.

10
00:00:51,390 --> 00:00:52,740
And of course, that didn't match.

11
00:00:53,130 --> 00:00:56,430
So it went to an error, and I believe I called it verify.

12
00:00:56,760 --> 00:00:58,260
So let me just navigate here.

13
00:00:59,410 --> 00:01:03,940
And then what you'll notice that the moment page loads.

14
00:01:05,120 --> 00:01:09,740
If I'm not loading, I go with a verified token.

15
00:01:10,220 --> 00:01:18,650
So that's the function that I'm invoking, and the inside of that function actually make a post request

16
00:01:18,920 --> 00:01:19,430
where.

17
00:01:20,270 --> 00:01:21,920
Well, we're just set up that route.

18
00:01:22,190 --> 00:01:22,530
Correct.

19
00:01:22,550 --> 00:01:27,710
Right before we set up the email functionality, what was the route verify email?

20
00:01:28,710 --> 00:01:36,220
And here I get a token, an email from query string parameters.

21
00:01:36,780 --> 00:01:40,920
So and here we set up a link with a query string parameters.

22
00:01:41,310 --> 00:01:45,270
So now back on my frontend, I grab those things.

23
00:01:46,170 --> 00:01:53,850
And then I set up a poster quest where app verification token as well as the email, just like we did

24
00:01:54,330 --> 00:01:55,200
in the Postman.

25
00:01:55,920 --> 00:01:57,090
Hopefully that is clear.

26
00:01:57,450 --> 00:02:06,300
And then if everything is correct, then we showcase account, confirm and we can go to a login.

27
00:02:06,630 --> 00:02:12,550
And if there is an error, which is going to be the case, if one of them is missing or that is already

28
00:02:12,550 --> 00:02:18,120
a second attempt where the verification token does not match cheering what we're getting back, then

29
00:02:18,330 --> 00:02:20,400
we will display that error.

30
00:02:20,880 --> 00:02:24,270
So that is as far as the front end is concerned.

31
00:02:24,390 --> 00:02:30,690
Now let's navigate back to the back end and let's discuss this origin because I think it's a very,

32
00:02:30,690 --> 00:02:31,860
very important topic.

33
00:02:31,980 --> 00:02:38,220
So in here, like I said, I went with local horse three thousand and probably your question is, well,

34
00:02:38,580 --> 00:02:40,050
OK, what about production?

35
00:02:40,440 --> 00:02:41,760
Well, it's as simple as that.

36
00:02:41,760 --> 00:02:49,110
So I go here once I push this up to production and I believe the name here was React Note and blah blah

37
00:02:49,110 --> 00:02:49,410
blah.

38
00:02:50,070 --> 00:02:53,220
Grab the URL, copy and paste and that's it.

39
00:02:53,400 --> 00:02:54,750
And you set up a origin.

40
00:02:54,750 --> 00:02:56,590
So I'm I guess I'm going to go with new origin.

41
00:02:56,640 --> 00:03:01,350
Just please keep in mind that, of course, I do need to use the same variable again.

42
00:03:01,350 --> 00:03:03,900
I removed the four slash and I'm good to go.

43
00:03:04,020 --> 00:03:05,340
That's exactly what I did.

44
00:03:05,700 --> 00:03:08,370
Now I do want to showcase Rob.

45
00:03:08,400 --> 00:03:16,440
Since we have that request object, we can get quite a few goodies in there that can come in really

46
00:03:16,440 --> 00:03:19,530
handy when you need to start constructing it.

47
00:03:19,950 --> 00:03:21,210
Now, what am I talking about?

48
00:03:21,750 --> 00:03:29,820
Well, first, let's just go with log and then I'll also do some console logging eventually here, just

49
00:03:29,820 --> 00:03:31,800
so you can clearly see what's happening.

50
00:03:32,070 --> 00:03:38,700
So for now, I'm just going to console log of the request, and in this case, I will make that request

51
00:03:39,180 --> 00:03:43,560
from the front and simply because when it comes to postman.

52
00:03:44,580 --> 00:03:45,990
Some things that are going to be missing.

53
00:03:46,530 --> 00:03:54,270
So therefore, let me go back to my three thousand and here eventually we'll be able to log out.

54
00:03:54,750 --> 00:04:00,690
But things will change the functionality there for the time being, it's not going to work.

55
00:04:01,230 --> 00:04:09,150
So what I want you to do is simply go to the application here where we have the cookies and just remove

56
00:04:09,150 --> 00:04:09,420
them.

57
00:04:09,870 --> 00:04:15,930
So just remove all of them fresh and basically you'll be able to start from scratch again.

58
00:04:16,470 --> 00:04:20,100
Yes, eventually we'll fix the functionality, but you have to wait.

59
00:04:21,000 --> 00:04:23,160
So let's go back to register on.

60
00:04:23,160 --> 00:04:32,070
I'm going to go with Susan, Susan and gmail.com, and then let's come up with some kind of password.

61
00:04:32,460 --> 00:04:37,680
And the only thing that I'm really looking for is the request object in a console.

62
00:04:37,680 --> 00:04:40,470
So you successfully were sent an email on that.

63
00:04:41,210 --> 00:04:42,630
What I'm looking for is this.

64
00:04:43,630 --> 00:04:48,730
And what I'm trying to show you is not the body, yes, we already know how to access that, but in

65
00:04:48,730 --> 00:04:53,110
here you get bunch and bunch of useful info.

66
00:04:53,830 --> 00:05:00,670
Effectively, you can use a bunch of things from here to construct that origin.

67
00:05:00,970 --> 00:05:08,740
Now you do need to keep some things in mind where your front end is behind proxy and eventually so will

68
00:05:08,740 --> 00:05:10,000
be your server.

69
00:05:10,360 --> 00:05:16,390
So that's why, in my opinion, it's definitely way easier like this where you just say, OK, if I

70
00:05:16,390 --> 00:05:21,790
know that I have only one front and application and it's going to be either in development here or in

71
00:05:21,790 --> 00:05:25,120
production here, then I just hardcoded them.

72
00:05:25,450 --> 00:05:32,050
But if you want to start looking for those values, whether that is where the server is located, whether

73
00:05:32,050 --> 00:05:35,800
that is where the request this coming from.

74
00:05:36,070 --> 00:05:37,960
Yes, you can get it from here.

75
00:05:38,230 --> 00:05:45,340
And most of the stuff is going to be sitting in the headers and effectively the way you access that

76
00:05:46,210 --> 00:05:51,140
you go with REC, get online, whatever is the header name again.

77
00:05:51,190 --> 00:05:55,000
This is a giant giant object, so there's tons of things in there.

78
00:05:55,000 --> 00:05:58,900
So therefore it is easier if you know what you're looking for.

79
00:05:59,200 --> 00:06:06,440
But in general, the headers is where effectively you'll be able to access most of the data.

80
00:06:06,460 --> 00:06:08,020
So, for example, in here, correct?

81
00:06:08,470 --> 00:06:09,700
I go with origin.

82
00:06:10,180 --> 00:06:11,170
Now what is the origin?

83
00:06:11,200 --> 00:06:14,520
Well, that is localhost 5000, and all of that is nice.

84
00:06:14,530 --> 00:06:22,600
But keep in mind that we're not sending the user, so we're not setting up our link to localhost 5000.

85
00:06:22,640 --> 00:06:24,190
That's where the servers.

86
00:06:24,430 --> 00:06:25,360
Now, why is it here?

87
00:06:25,360 --> 00:06:25,930
5000?

88
00:06:25,960 --> 00:06:27,370
Well, because we have a proxy.

89
00:06:27,730 --> 00:06:28,150
Correct.

90
00:06:28,450 --> 00:06:33,430
And therefore, that's what I'm saying that once you start setting up the proxies and all that, it

91
00:06:33,430 --> 00:06:36,130
gets really tricky, really fast.

92
00:06:36,580 --> 00:06:44,960
So in this case, if I want to see what is the original one, I need to go with this one, be forwarded

93
00:06:44,960 --> 00:06:48,370
to host what I can see that it's actually coming from three thousand.

94
00:06:48,730 --> 00:06:52,210
I can see the protocol, I can see the port and all of that cool stuff.

95
00:06:52,390 --> 00:06:56,560
So let me just log some stuff just so you have an idea.

96
00:06:56,950 --> 00:06:58,930
So in my case, I'm going to stick with origin.

97
00:06:59,440 --> 00:07:06,070
And then if you ever want to go with production one, then just the proper URL.

98
00:07:06,190 --> 00:07:10,780
Now what things I want to showcase, I'm going to go here with content and protocol.

99
00:07:11,660 --> 00:07:15,860
Protocol matters equal to request protocol.

100
00:07:16,370 --> 00:07:18,350
That's the property on the object.

101
00:07:18,670 --> 00:07:22,390
Then if we want to get the host, we go with consent.

102
00:07:22,690 --> 00:07:27,280
And I say, no, I actually want it to log this protocol run.

103
00:07:27,800 --> 00:07:30,620
Want to go with concert host is equal to Iraq.

104
00:07:31,580 --> 00:07:33,860
Get more than for host.

105
00:07:34,250 --> 00:07:35,870
Again, that's the syntax.

106
00:07:36,050 --> 00:07:41,480
You have a header and then you just go with get and then whatever is the header name.

107
00:07:42,020 --> 00:07:45,050
So let's also log that host.

108
00:07:45,680 --> 00:07:52,550
And if you want, you can add maybe here a protocol protocol, maybe that's going to make a little bit

109
00:07:52,550 --> 00:07:53,210
more sense.

110
00:07:54,020 --> 00:08:00,350
So let me cut it out here and I'll set up properly where access the variable and.

111
00:08:01,400 --> 00:08:02,900
Copy and paste the protocol.

112
00:08:03,260 --> 00:08:04,610
So let me do it here as well.

113
00:08:05,480 --> 00:08:09,140
You're also a host just so we can have a cleaner council.

114
00:08:10,230 --> 00:08:19,890
Host here and then let me showcase the forwarded host and forwarded protocol, so concert for word that.

115
00:08:20,900 --> 00:08:32,090
And I'll just say host, so wreck and get the name and the name here is X forwarded and we go in host.

116
00:08:32,630 --> 00:08:36,230
And the same copy and paste and now we're looking for a protocol.

117
00:08:37,309 --> 00:08:47,480
Protocol now will be equal to the header by the name of protocol, and the line led to similar console.log.

118
00:08:48,670 --> 00:08:50,530
Where we go with for that host.

119
00:08:51,890 --> 00:09:00,110
We're word that host and then we have the venerable, of course, so forward that most copy and paste

120
00:09:00,680 --> 00:09:03,260
and let's set it up protocol as well.

121
00:09:03,620 --> 00:09:08,260
And as a side note, when it comes to a postman.

122
00:09:08,270 --> 00:09:16,790
So when you're sending this from a postman and you're logging the origin basically where it is coming

123
00:09:16,790 --> 00:09:17,150
from.

124
00:09:17,480 --> 00:09:22,250
Effectively, what you'll get back is now so nothing.

125
00:09:22,910 --> 00:09:26,540
So let me set up here the protocol, and then I'll show you one more thing.

126
00:09:26,840 --> 00:09:28,100
So for the protocol?

127
00:09:28,250 --> 00:09:31,310
And remember the what was the origin correct?

128
00:09:31,820 --> 00:09:33,020
Somewhere here was the origin.

129
00:09:33,020 --> 00:09:36,560
I showcased the local host 5000, so I can definitely check that.

130
00:09:36,570 --> 00:09:42,930
But remember, Mike already said probably a million times when it comes to proxies and everything.

131
00:09:43,100 --> 00:09:48,950
It's not as straightforward as it looks, so let me go here with Konst.

132
00:09:49,190 --> 00:09:56,150
Origin is equal to and again, this is really optional just so you kind of get the overall picture.

133
00:09:56,760 --> 00:09:59,240
There's really nothing that you have to do in this project.

134
00:09:59,690 --> 00:10:04,300
Let me go here with log on or you're pretty much the same thing.

135
00:10:04,310 --> 00:10:05,870
I'm just going to showcase the origin.

136
00:10:06,620 --> 00:10:08,780
So we're going to go here with origin.

137
00:10:09,590 --> 00:10:11,570
And this is the case where, yes.

138
00:10:11,660 --> 00:10:12,650
One last time.

139
00:10:12,920 --> 00:10:15,800
We will have to set up some kind of random user.

140
00:10:15,800 --> 00:10:18,580
And again, in between the videos, I'll clean out my database.

141
00:10:18,590 --> 00:10:23,060
I know that for some people, it's probably annoying, but that's just the way it is.

142
00:10:23,090 --> 00:10:24,290
So let me go back.

143
00:10:25,730 --> 00:10:30,740
I'm going to navigate back to register or just there one more time I may go with Susan in this case.

144
00:10:30,740 --> 00:10:33,260
Or maybe I already went with Susan Pavitt.

145
00:10:33,260 --> 00:10:35,060
Maybe buried.

146
00:10:36,230 --> 00:10:44,510
David, and then for I forget, I don't want to log the big request because it's going to be too much

147
00:10:44,510 --> 00:10:48,460
info, go Gmail and then let's set up as secret.

148
00:10:48,840 --> 00:10:52,730
Let's register and it looks like I have an error.

149
00:10:53,180 --> 00:11:03,230
So let me go back to my server and I can see that identifier origin has already been declared my bad.

150
00:11:03,950 --> 00:11:07,700
So let me say here Camp Origin.

151
00:11:10,070 --> 00:11:11,120
Not origin.

152
00:11:11,930 --> 00:11:15,650
And I'm still going to be looking for the same header, so that's not going to change.

153
00:11:16,340 --> 00:11:18,980
We're just going to say dump origin.

154
00:11:19,820 --> 00:11:22,040
Now let's go back.

155
00:11:22,260 --> 00:11:23,570
Let's try to send.

156
00:11:23,930 --> 00:11:24,680
We're loading.

157
00:11:25,020 --> 00:11:25,700
Great, awesome.

158
00:11:26,120 --> 00:11:31,740
So now we're sending the email, but what we're really interested is this scenario.

159
00:11:32,240 --> 00:11:38,660
This is going to be the origin, which again, where do you request this coming from, which is 5000?

160
00:11:39,380 --> 00:11:43,490
And if that's not what we need, what we need is 3000.

161
00:11:43,490 --> 00:11:44,510
Where is that located?

162
00:11:44,960 --> 00:11:46,850
That is in the forward host.

163
00:11:47,210 --> 00:11:47,570
Correct.

164
00:11:47,960 --> 00:11:49,110
Now what about protocol?

165
00:11:49,130 --> 00:11:50,230
This is a leap.

166
00:11:50,390 --> 00:11:57,260
So of course, once we publish this, most likely it's going to be actually itbs also something that

167
00:11:57,260 --> 00:11:59,840
we can get from the headers run.

168
00:12:00,380 --> 00:12:02,540
Let's take a look at the host.

169
00:12:02,960 --> 00:12:05,180
And basically, this is our server.

170
00:12:05,190 --> 00:12:10,240
So I fully understand that this might be a little bit confusing where you have origin and host.

171
00:12:10,250 --> 00:12:13,820
Just remember, this is because we have a proxy on a frontend.

172
00:12:14,210 --> 00:12:16,970
So in my case, here's what I'm going to do.

173
00:12:17,450 --> 00:12:21,860
I'm going to remove console logs.

174
00:12:23,140 --> 00:12:30,610
I think that they will be on a way for you, but I will leave these values for you just in case you

175
00:12:30,610 --> 00:12:31,630
ever need a reference.

176
00:12:31,750 --> 00:12:33,280
Let me remove these kinds of logs.

177
00:12:34,660 --> 00:12:36,760
And we're pretty much good to go.

178
00:12:37,090 --> 00:12:41,440
Now I want to set up a refresh token functionality.

