1
00:00:00,240 --> 00:00:00,810
Wonderful.

2
00:00:00,930 --> 00:00:06,570
So knowledge is complete, the verification, we're effectively the steps are following.

3
00:00:07,350 --> 00:00:11,070
We want to check for user using the email.

4
00:00:11,880 --> 00:00:21,000
If there is no user, we send back for a one, if the token that we're getting does not match to whatever

5
00:00:21,180 --> 00:00:24,780
token we have in a user because remember, that's what we did in register.

6
00:00:25,140 --> 00:00:29,160
We did set up that token over one again we send back for.

7
00:00:30,030 --> 00:00:33,270
And if everything is correct, here's what we want to do.

8
00:00:33,870 --> 00:00:39,180
We want to set is verified and as a side note, my typing is just awesome.

9
00:00:40,270 --> 00:00:40,870
Too true.

10
00:00:41,560 --> 00:00:50,620
So what that means is that when we use logging, we'll be successful, we will set up the verified equal

11
00:00:50,620 --> 00:00:57,670
to date that now basically when that happen and verification token will set back to an empty string.

12
00:00:58,000 --> 00:01:02,170
That's why we're now showcasing before the final frontend.

13
00:01:02,440 --> 00:01:08,170
The second time when we refreshed the page already on the front end, we were getting back the error.

14
00:01:08,710 --> 00:01:14,110
And that's the case because at that point, verification token is already an empty string.

15
00:01:14,620 --> 00:01:17,920
And then we just want to save it using the instants method.

16
00:01:18,340 --> 00:01:25,420
So remember, that was an option that we can take whenever we use, but save on instance online as far

17
00:01:25,420 --> 00:01:30,130
as the return will go with message and email verified.

18
00:01:30,580 --> 00:01:35,920
So let's try this one out and navigate back to your off controller.

19
00:01:36,310 --> 00:01:39,940
And so once again, this is already our, I believe, ninth project.

20
00:01:40,690 --> 00:01:46,330
I'm pretty sure that we can handle if we set up the entire functionality and then we test it.

21
00:01:46,660 --> 00:01:48,400
So I'm looking for those two things.

22
00:01:48,880 --> 00:01:51,160
Verification, token and email.

23
00:01:52,030 --> 00:01:54,850
I want to find my user using the email.

24
00:01:55,060 --> 00:01:55,960
How can I do that?

25
00:01:55,990 --> 00:01:58,090
Well, we can go with Konst.

26
00:01:59,650 --> 00:02:03,940
So user is equal to Oh wait, and what was the method?

27
00:02:04,300 --> 00:02:04,900
Find one.

28
00:02:05,350 --> 00:02:12,130
So we're going to go with user, find one online and here, let's use email.

29
00:02:12,790 --> 00:02:17,320
So I want to find a user whose email matches this one.

30
00:02:17,920 --> 00:02:23,560
Now, if I'm not successful, if there is no user, what do we do?

31
00:02:23,830 --> 00:02:26,470
We throw for all one?

32
00:02:27,440 --> 00:02:29,720
So in this case, I'm going to go with the bureau.

33
00:02:30,620 --> 00:02:37,280
You know, and we're looking for custom error dot and then on authenticated.

34
00:02:37,580 --> 00:02:38,000
Correct.

35
00:02:38,450 --> 00:02:40,490
And let's just say verification failed.

36
00:02:41,580 --> 00:02:42,090
Failed.

37
00:02:42,930 --> 00:02:43,430
Awesome.

38
00:02:44,040 --> 00:02:50,100
Now I want to check whether the verification token actually matches to what I'm getting here.

39
00:02:51,000 --> 00:02:52,020
What is the proper name?

40
00:02:52,050 --> 00:02:55,740
Well, it is not a non verification token, correct?

41
00:02:56,110 --> 00:03:01,020
Now if you need just go and double check in the Mongo one in the graphical interface and you'll see

42
00:03:01,020 --> 00:03:01,700
that that's the case.

43
00:03:01,710 --> 00:03:04,470
So go here with user verification token.

44
00:03:04,890 --> 00:03:11,300
If it's not equal to whatever I'm getting here, well, Ron, we have a problem, correct?

45
00:03:11,820 --> 00:03:12,870
So we'll go back here.

46
00:03:13,020 --> 00:03:16,380
Copy and paste and send back the same thing.

47
00:03:16,730 --> 00:03:22,290
I'll say, Hey, check the verification token because there seems to be a problem.

48
00:03:22,800 --> 00:03:25,800
Now, if we are good, what that means.

49
00:03:26,310 --> 00:03:31,380
Well, that means that we just need to set user equal to verify.

50
00:03:31,800 --> 00:03:36,600
So then the user can go back to a long page and actually access the application correct?

51
00:03:36,810 --> 00:03:37,560
How do we do that?

52
00:03:37,590 --> 00:03:39,240
Well, we're going user.

53
00:03:39,570 --> 00:03:44,320
And first, let's go with is verify is equal to true then.

54
00:03:44,760 --> 00:03:47,920
What I want to do is set verified equal to that.

55
00:03:47,920 --> 00:03:48,360
Not now.

56
00:03:48,570 --> 00:03:52,410
So user verified is equal to date.

57
00:03:53,100 --> 00:03:53,910
Not now.

58
00:03:54,210 --> 00:03:59,280
And then lastly, let's set up the verification token equal to an empty string.

59
00:03:59,310 --> 00:04:04,780
So go here with user verification token is equal to an empty string.

60
00:04:04,800 --> 00:04:10,830
So the second time, let's say, right after, if you make a request, it's not going to work because

61
00:04:11,130 --> 00:04:17,519
verification token won't match anymore of this one because this one will be already an empty string.

62
00:04:17,550 --> 00:04:20,339
Hopefully, that makes sense when we want to save the user.

63
00:04:20,790 --> 00:04:25,380
So go here with a wait and not user, not save.

64
00:04:25,650 --> 00:04:30,810
And then lastly, like I said, as far as what we're sending back and I'm going to send back or send

65
00:04:30,810 --> 00:04:35,610
more, I'll just go with message and an email verified.

66
00:04:36,150 --> 00:04:39,690
So then the frontend just decides what to do.

67
00:04:39,870 --> 00:04:45,000
You are to guide the user right away to a logging page or something along those lines.

68
00:04:45,210 --> 00:04:47,880
So now let's hop back to a spokesman.

69
00:04:48,880 --> 00:04:54,550
And here what we're looking for is, of course, a route.

70
00:04:55,240 --> 00:04:59,980
So let me send that and yep, I have email verified.

71
00:05:00,010 --> 00:05:07,240
Now what that means is that I can go through logging user and then if I go with beta, I should get

72
00:05:07,240 --> 00:05:08,320
my cookie correct.

73
00:05:08,740 --> 00:05:12,520
So we're sitting here and yep, I'm going to go my cookies.

74
00:05:12,850 --> 00:05:14,950
I have successfully logged in.

75
00:05:15,770 --> 00:05:18,550
Now let's try one more time with brand new user.

76
00:05:19,470 --> 00:05:26,070
I mean, I'm having a problem coming up with names, but I will try to go with David, hopefully I don't

77
00:05:26,070 --> 00:05:28,230
have it here, so go with David.

78
00:05:29,070 --> 00:05:33,000
We successfully registered, but if I'll try to log in.

79
00:05:33,980 --> 00:05:37,190
I shouldn't because we haven't verified.

80
00:05:37,310 --> 00:05:37,640
Correct.

81
00:05:37,970 --> 00:05:40,850
So we have here, please verify your email.

82
00:05:41,390 --> 00:05:43,190
And now let's do this.

83
00:05:43,520 --> 00:05:45,500
Let's go here with David.

84
00:05:46,740 --> 00:05:48,600
David and.

85
00:05:49,620 --> 00:05:52,590
We're just three years there, I want to think of a slogan instead.

86
00:05:53,740 --> 00:05:56,860
So we're finding now we're looking for this token.

87
00:05:57,460 --> 00:06:00,040
Let's add a comma to verify it.

88
00:06:00,530 --> 00:06:06,400
I said the second time also and will get verification failed because no verification token is set to

89
00:06:06,400 --> 00:06:07,300
an empty string.

90
00:06:07,480 --> 00:06:09,840
But we know initially that worked.

91
00:06:09,840 --> 00:06:11,620
So now I can go to a logging one.

92
00:06:11,980 --> 00:06:18,880
And while I successfully can log in as David now in between the video and just so you don't have to

93
00:06:18,880 --> 00:06:25,390
watch me, I will go and delete all the users so I can start from scratch and I highly encourage you

94
00:06:25,870 --> 00:06:26,590
to do the same.

95
00:06:27,040 --> 00:06:33,460
But with this in place now, I can move on and start finally setting up our emails.

