1
00:00:00,210 --> 00:00:07,320
All right, and before we implement the longer functionality in our interceptor and as a result in our

2
00:00:07,320 --> 00:00:09,780
application, let's discuss quickly why.

3
00:00:10,170 --> 00:00:16,980
So when I'm trying to update some user data, if one of the barriers is missing, I'm getting back this

4
00:00:16,980 --> 00:00:20,310
400, which means, well, it's a bad request.

5
00:00:20,730 --> 00:00:27,540
So essentially, user either needs to add the correct value or he or she just needs to navigate to the

6
00:00:27,780 --> 00:00:28,350
other page.

7
00:00:28,350 --> 00:00:33,960
And then when they come back normal again, this is going to be the default value that is coming from

8
00:00:33,960 --> 00:00:34,560
the database.

9
00:00:35,010 --> 00:00:35,970
Hopefully, that is clear.

10
00:00:36,620 --> 00:00:40,020
Now what would be other possible errors that we get?

11
00:00:40,200 --> 00:00:47,070
Well, we could get five hundred, which is that generic server error, but we can also get for a one

12
00:00:47,670 --> 00:00:48,480
one two four one.

13
00:00:48,930 --> 00:00:51,720
Well, that is unauthorized, correct?

14
00:00:52,290 --> 00:00:56,820
And here's what we need to think about if we're heading here for a one.

15
00:00:57,660 --> 00:01:00,330
Should the user be in the application in the first place?

16
00:01:01,110 --> 00:01:03,060
And what would be the scenario?

17
00:01:03,090 --> 00:01:08,040
Well, the scenario is that, let's say, user logged in and everything is fine and dandy.

18
00:01:08,040 --> 00:01:11,220
But at some point the token expired.

19
00:01:11,940 --> 00:01:15,750
Wouldn't it make more sense if we get back for a one?

20
00:01:16,050 --> 00:01:21,300
We actually log out the user right instead of just displaying that there's an error.

21
00:01:21,300 --> 00:01:28,200
So let me showcase that I'm going to go back to my app context and I'll do the same thing like we already

22
00:01:28,200 --> 00:01:31,710
did in one of the previous videos where I'm just going to comment on the token.

23
00:01:32,040 --> 00:01:37,470
Now again, keep in mind what I'm trying to showcase here is the Aspire token.

24
00:01:38,280 --> 00:01:40,200
I just don't want to go through the server and all that.

25
00:01:40,410 --> 00:01:45,240
But the idea is going to be exactly the same way if this token is not present.

26
00:01:45,630 --> 00:01:49,080
What we're going to get back is not the 400 show.

27
00:01:49,080 --> 00:01:55,620
We will get the 401 and in here now, even with all the values providing all that, I'm going to get

28
00:01:55,620 --> 00:01:57,120
this authentication round.

29
00:01:57,510 --> 00:02:01,980
And again, let me address the question one more time.

30
00:02:02,700 --> 00:02:06,210
What do you think makes more sense if you get four to one?

31
00:02:06,900 --> 00:02:08,400
So essentially, you're not authorized?

32
00:02:08,759 --> 00:02:15,240
Does it make sense to display that or kick out the user and then make sure that he or she logs back

33
00:02:15,240 --> 00:02:15,420
in?

34
00:02:15,630 --> 00:02:20,970
And of course, the answer is the second one where essentially you want to log out the user and make

35
00:02:20,970 --> 00:02:23,430
sure that all the credentials are in place.

36
00:02:23,730 --> 00:02:24,630
Now, how do we do that?

37
00:02:24,660 --> 00:02:28,230
Well, remember, we have right now our request and all that.

38
00:02:28,590 --> 00:02:30,090
I mean, everything is beautiful.

39
00:02:30,090 --> 00:02:36,180
We can save it here and make sure that we have the token and where we have the response.

40
00:02:36,180 --> 00:02:43,800
One, instead of just logging, what is the functionality for us that does the long, hard slog out

41
00:02:43,800 --> 00:02:44,690
user correct?

42
00:02:45,120 --> 00:02:52,320
So we're keeping score and keep on scrolling somewhere here who have the user dispatch, as well as

43
00:02:52,320 --> 00:02:56,670
removal from the local storage and instead of just logging something.

44
00:02:57,590 --> 00:03:02,150
The off air or whatever, I actually want to invoke dysfunction.

45
00:03:02,420 --> 00:03:06,590
I want to go here with logout user and invoke it.

46
00:03:06,890 --> 00:03:07,310
You know what?

47
00:03:07,700 --> 00:03:11,480
I think I was in too much of a hurry, actually.

48
00:03:11,960 --> 00:03:13,010
Still want to showcase this?

49
00:03:13,310 --> 00:03:13,940
My apologies.

50
00:03:14,090 --> 00:03:17,930
So now let's notice something where I'm going to go back to my application.

51
00:03:18,050 --> 00:03:19,300
All the values are here.

52
00:03:19,310 --> 00:03:20,300
Everything is correct.

53
00:03:20,570 --> 00:03:25,550
But since I have the token missing, I will be logged out as I should be.

54
00:03:25,850 --> 00:03:32,120
Now, one thing that I kind of want to quickly mention is the fact that we'll still display this arrow

55
00:03:32,120 --> 00:03:37,550
here, the alert, or simply because I mean, it takes time for us to remove it.

56
00:03:37,910 --> 00:03:38,270
Correct.

57
00:03:38,300 --> 00:03:40,370
Remember, we were doing that delay thing.

58
00:03:40,610 --> 00:03:44,700
So let me just quickly show cause that where I'm going to go with email.

59
00:03:44,720 --> 00:03:47,690
And if I remember correctly, it was Susan now.

60
00:03:47,960 --> 00:03:50,000
Now I believe my password is still secret.

61
00:03:50,390 --> 00:03:52,100
Hopefully, I didn't mess that one up.

62
00:03:52,430 --> 00:03:57,650
And again, let me quickly show something more once I go here and then I go to register notice.

63
00:03:57,980 --> 00:04:01,310
You'll get this alert for a little bit because we have that delay.

64
00:04:01,580 --> 00:04:02,900
Now, why am I showing that?

65
00:04:03,230 --> 00:04:08,570
Not only what I want to do is log out user here if it is for one?

66
00:04:09,710 --> 00:04:13,370
I also want to go to my update user over here.

67
00:04:13,730 --> 00:04:18,890
And I actually want to dispatch this one only if it's not for one.

68
00:04:19,370 --> 00:04:23,890
So essentially, if it's for one, I mean, there's really no point to showing that alert, correct

69
00:04:24,110 --> 00:04:28,250
and how we can do that while we're here, I can just set up the if condition where I'm going to go with

70
00:04:28,250 --> 00:04:33,320
error, then that response response status.

71
00:04:33,560 --> 00:04:38,750
And I'll just say, if it's not for one, then display there otherwise.

72
00:04:38,750 --> 00:04:40,430
I mean, you don't have to do anything.

73
00:04:40,820 --> 00:04:47,120
And yes, to answer your question, you can also attach, for example, five hundred in the log out

74
00:04:47,330 --> 00:04:48,200
as well as here.

75
00:04:48,500 --> 00:04:49,580
I mean, that kind of makes sense.

76
00:04:49,850 --> 00:04:55,120
If the server is not working properly, the user shouldn't be sitting in the front me anyway.

77
00:04:55,400 --> 00:04:56,480
So I'm going to go over here.

78
00:04:56,510 --> 00:05:00,710
I'll say if it's not for one, and then let's take this one over here.

79
00:05:01,010 --> 00:05:01,940
Let's say it.

80
00:05:02,240 --> 00:05:05,180
And now let's go back to our front end application one more time.

81
00:05:05,450 --> 00:05:07,330
So let me quickly log in again.

82
00:05:07,340 --> 00:05:09,020
I know you're probably sick of this, but.

83
00:05:10,030 --> 00:05:10,780
Mean, just do that.

84
00:05:11,170 --> 00:05:16,990
I'm going to go here, I'm going to log in again, I'll provide all the values, so that should be correct.

85
00:05:17,510 --> 00:05:23,320
And then let me go and I'll quickly show that there is an alert in this case.

86
00:05:23,590 --> 00:05:29,590
Again, you might say it's an extra step, but in my opinion, since we're setting up that delay, it

87
00:05:29,590 --> 00:05:32,140
kind of makes sense over here that we're not displaying the alert.

88
00:05:32,560 --> 00:05:36,970
Again, let me repeat, if there would be no delay, this wouldn't be necessary.

89
00:05:37,240 --> 00:05:38,060
Well, right away.

90
00:05:38,080 --> 00:05:39,190
Log out the user.

91
00:05:39,490 --> 00:05:45,070
So that way there's not going to be sending that message over there because keep in mind that we set

92
00:05:45,070 --> 00:05:51,520
this up and then there's that delay for us to remove in my case right away, just remove it when we

93
00:05:51,520 --> 00:05:52,360
invoke the function.

94
00:05:52,630 --> 00:05:54,190
Hopefully, that makes sense.

95
00:05:54,400 --> 00:05:59,920
And before we start setting up the jobs in our application, so essentially, we'll start with the model.

96
00:05:59,920 --> 00:06:02,560
We set up the controller and you already know the drill.

97
00:06:03,010 --> 00:06:08,890
I also want to clean up the app context a little bit where I will comment out of this log.

98
00:06:09,370 --> 00:06:11,860
So essentially, if you want to keep it, it's definitely an option.

99
00:06:11,860 --> 00:06:14,110
In my case, I will comment this one out.

100
00:06:14,110 --> 00:06:18,280
I will uncomment the Birtukan you the request one.

101
00:06:18,460 --> 00:06:22,930
So this one was in response, more specifically in the error callback function.

102
00:06:23,260 --> 00:06:27,010
Now this is going to be in the request one in the callback function.

103
00:06:27,370 --> 00:06:31,690
So a definitely, definitely definitely want to add that token over here.

104
00:06:32,050 --> 00:06:32,890
And then remember.

105
00:06:33,850 --> 00:06:36,270
In a profile, we comment this one, correct.

106
00:06:36,520 --> 00:06:39,280
While we were testing well, we're done with testing.

107
00:06:39,670 --> 00:06:45,460
Just keep in mind that from this point on, we'll be checking for those antibodies right away in the

108
00:06:45,460 --> 00:06:45,740
front.

109
00:06:46,720 --> 00:06:52,930
So if you all try to test the for hire response, I mean, it's not going to work because we'll right

110
00:06:52,930 --> 00:06:56,560
away check for it or we're here and with these changes in place.

111
00:06:56,860 --> 00:06:59,200
Now we can start setting up jobs in our application.

