1
00:00:01,600 --> 00:00:04,270
The last video we saw, what do we mean by cookies?

2
00:00:04,660 --> 00:00:07,900
But in this video, we'll see what is a session for?

3
00:00:07,900 --> 00:00:12,070
Session is a period of time when a browser interacts with a server.

4
00:00:12,880 --> 00:00:18,730
So basically, when we log in to a web site, the session starts and a cookie gets created.

5
00:00:19,420 --> 00:00:26,550
So whenever we need to use a page that requires authentication, they always check against that acto

6
00:00:26,560 --> 00:00:32,530
cookie that is there on our browser session ends when we log or cookie that is related to the session

7
00:00:32,530 --> 00:00:33,340
gets destroyed.

8
00:00:33,790 --> 00:00:37,600
So basically when we open a website.

9
00:00:41,710 --> 00:00:42,870
They're the browser.

10
00:00:44,620 --> 00:00:49,000
Chicks caught up after cookie cutter active session.

11
00:00:51,220 --> 00:00:57,880
So, for example, if you are logging into your Facebook or some other social networking app, you need

12
00:00:57,880 --> 00:01:00,190
to log in using the password every time.

13
00:01:00,520 --> 00:01:05,170
So once you log in, it will be remembered, you know, remember me for some time, I remember me for

14
00:01:05,170 --> 00:01:09,520
a month, but they basically they're creating a session for that much amount of time.

15
00:01:09,970 --> 00:01:15,160
So when they're following your browser finds the accusation, it will not ask for the password of genetically

16
00:01:15,160 --> 00:01:15,550
logging.

17
00:01:16,030 --> 00:01:21,730
Only when you click log out, then that cookie gets related to that session gets destroyed.

18
00:01:22,150 --> 00:01:22,570
OK.

19
00:01:23,080 --> 00:01:24,130
This is what happens.

20
00:01:24,880 --> 00:01:27,100
So this is what session means.

21
00:01:27,730 --> 00:01:31,120
It is basically a time in the browser in Bratislava.

22
00:01:31,540 --> 00:01:36,340
And then based on this session, will create cookies that do cookies and destroy the cookies and everything.

23
00:01:36,820 --> 00:01:40,900
So hullabaloo that OK be have understood the theory of setting up like, you know, creating cookies

24
00:01:40,900 --> 00:01:47,530
and sessions and then destroying them and everything, but how to implement that in the code from then?

25
00:01:47,650 --> 00:01:49,690
That is where the passport comes in.

26
00:01:50,080 --> 00:01:51,160
We lose passports.

27
00:01:51,310 --> 00:01:55,630
It is basically a simple and unobtrusive authentication for Node.js.

28
00:01:56,500 --> 00:02:02,710
It up all sort of strategy supporting authentication like using username and password, using Google,

29
00:02:02,710 --> 00:02:05,670
using Facebook, using Twitter and more for passport.

30
00:02:05,830 --> 00:02:09,580
Jazz is something that everybody uses in its website.

31
00:02:10,240 --> 00:02:11,350
And what are the documentation?

32
00:02:11,360 --> 00:02:12,340
This is the website for it.

33
00:02:13,130 --> 00:02:17,140
It will have many things it will have Google logged and everything.

34
00:02:17,980 --> 00:02:24,370
So here, if you see it, it is a passport, Facebook passport, Twitter, Google or lot.

35
00:02:25,030 --> 00:02:31,180
And then it will have many things like GitHub and it will get a passport so you can log in and do everything

36
00:02:31,180 --> 00:02:35,710
the Google authentication part will see in the next related to final video.

37
00:02:35,980 --> 00:02:41,830
So before that, there is one thing that you have to know how to install this passport, jazz and everything.

38
00:02:42,550 --> 00:02:45,310
So for that, we'll see some quotes.

39
00:02:47,920 --> 00:02:50,770
The first thing we have to require all the packages.

40
00:02:51,200 --> 00:02:53,660
So what are all the packages that we have to request?

41
00:02:54,110 --> 00:02:55,790
So there will be an Bayamon start.

42
00:02:56,090 --> 00:03:00,110
It is the basic code and payment style for everything and what we have to construct.

43
00:03:00,860 --> 00:03:02,330
We have to install a passport.

44
00:03:02,870 --> 00:03:06,230
We have to install passport local.

45
00:03:07,370 --> 00:03:08,390
We have to install.

46
00:03:10,320 --> 00:03:12,330
Passport local.

47
00:03:13,780 --> 00:03:14,500
Mongoose.

48
00:03:15,280 --> 00:03:19,270
And then we have trained start express suspicion.

49
00:03:21,300 --> 00:03:21,720
So.

50
00:03:22,910 --> 00:03:29,450
Once we install them, you can require all the install packages if you've got to gorgeous.

51
00:03:29,960 --> 00:03:34,970
You can request all of them like passport, local mungo's passport session and everything.

52
00:03:35,540 --> 00:03:41,420
But one thing that is not required is passport local because it is one of the dependencies that will

53
00:03:41,420 --> 00:03:43,460
be needed by the passport local most.

54
00:03:43,970 --> 00:03:45,650
No need to record it explicitly.

55
00:03:45,980 --> 00:03:48,740
So this passport, this is a soft model of that.

56
00:03:49,130 --> 00:03:55,130
This is just a model of this passport local man was wanted to export, you know, required this separately

57
00:03:55,400 --> 00:03:56,120
explicitly.

58
00:03:56,930 --> 00:04:00,380
So after doing this, we have bought initialize the session.

59
00:04:01,190 --> 00:04:02,720
So how to initialize the session?

60
00:04:03,050 --> 00:04:10,700
This is also being of the session is I've got use session will send the secret resales false save and

61
00:04:11,570 --> 00:04:13,280
save on initializes.

62
00:04:13,970 --> 00:04:17,630
So this call we got from the documentation, you can check for the documentation here.

63
00:04:18,530 --> 00:04:23,390
Everything will be in clear format, but we'll see the code that is required for our.

64
00:04:24,800 --> 00:04:30,910
After doing this, this is basically initializing this app, not use passport, not initialize.

65
00:04:31,520 --> 00:04:32,300
So if you see this?

66
00:04:33,400 --> 00:04:35,730
Yeah, it is, I guess.

67
00:04:35,750 --> 00:04:35,920
Yeah.

68
00:04:37,440 --> 00:04:42,960
So if you see this court produce passport initialise, so I have initialized the passport and of initializing,

69
00:04:42,960 --> 00:04:50,790
we have to use the session after this passport session and then at Passport Local Man List, what one

70
00:04:50,940 --> 00:04:51,480
schema.

71
00:04:52,320 --> 00:04:57,210
So we'll basically add this plugin passport local English to the user schema.

72
00:04:58,230 --> 00:05:04,140
This is what we are going to use to hash in certain passwords and to save up use to database.

73
00:05:04,500 --> 00:05:06,420
OK, schema should be a mongoose chemo.

74
00:05:06,930 --> 00:05:11,670
So basically, if you are not using passport, even if you don't write, this one was keyboard, it

75
00:05:11,670 --> 00:05:12,120
will work.

76
00:05:12,690 --> 00:05:17,730
But since we are losing passport and then using passport plugins for that schema, here it should be

77
00:05:17,730 --> 00:05:18,630
a mongoose schema.

78
00:05:20,450 --> 00:05:24,410
So then using the passport local configuration, we can create strategies.

79
00:05:24,920 --> 00:05:28,760
So this strategies that can be, you know, I'll show you.

80
00:05:28,950 --> 00:05:29,560
Yeah, it can be.

81
00:05:29,570 --> 00:05:33,800
Global strategy can be a Facebook strategy on all this kind of stuff.

82
00:05:34,430 --> 00:05:38,450
So once we create the strategies, we'll see, it's creating strategies in the next Twitter that is

83
00:05:38,450 --> 00:05:39,680
Google authentication.

84
00:05:40,490 --> 00:05:45,740
Then serialize and DC delays are useful when we're creating sessions.

85
00:05:45,980 --> 00:05:48,800
So what is serialize serialize means?

86
00:05:49,960 --> 00:05:51,340
I will write it.

87
00:05:52,420 --> 00:05:54,400
So what do you mean by we?

88
00:05:55,950 --> 00:05:56,850
Legalized means.

89
00:05:58,440 --> 00:05:59,340
Create a cookie.

90
00:06:00,700 --> 00:06:02,320
And store information inside it.

91
00:06:04,010 --> 00:06:04,760
And store.

92
00:06:06,440 --> 00:06:10,430
Information inside it any more than we would be.

93
00:06:11,940 --> 00:06:12,660
Serialize.

94
00:06:14,070 --> 00:06:14,970
This basically.

95
00:06:16,200 --> 00:06:20,280
Crumble the cookie and retrieve the information, crumble the cookie.

96
00:06:22,550 --> 00:06:25,010
And retrieve the information.

97
00:06:26,500 --> 00:06:28,920
This is what I mean by these intelligence serialize.

98
00:06:29,770 --> 00:06:34,990
So if you've got any deprecation warnings, search them in Google to find the solutions.

99
00:06:35,620 --> 00:06:35,980
OK.

100
00:06:38,600 --> 00:06:44,710
So one thing we can do, right, but get pushed out score by checking the passport, local mungo's documentation

101
00:06:44,720 --> 00:06:46,010
and BMJ is dot com.

102
00:06:46,880 --> 00:06:47,240
OK.

103
00:06:47,510 --> 00:06:52,910
So for registering, we can check the documentation of Passport Local Mongoose for logging and log what

104
00:06:52,910 --> 00:06:56,390
you can check the documentation for passport just or documentation.

105
00:06:57,080 --> 00:06:57,440
OK.

106
00:06:59,560 --> 00:07:02,680
So one word of advice quickly gets deleted with no relation to seven.

107
00:07:05,090 --> 00:07:11,060
So if you see this here, this is initializing everything, and then we are using the schema and then

108
00:07:11,060 --> 00:07:16,600
we using created start again, then serialized user DC realizes he's a realizes it is a disease, as

109
00:07:16,640 --> 00:07:19,100
you know, I want to give it to resources.

110
00:07:19,850 --> 00:07:27,330
So here you can search for the log in and logout caught in this documentation and in that vein being

111
00:07:27,350 --> 00:07:28,010
passport.

112
00:07:32,950 --> 00:07:38,510
And that in the pocket baggage password passport, you can search for the register like you can see

113
00:07:38,510 --> 00:07:40,210
serialized user serialized user.

114
00:07:41,270 --> 00:07:45,950
And then logging strategies, and they will be done in this tool documentation, you can go to it.

115
00:07:46,340 --> 00:07:50,900
But the basic idea is we have to understand what you are doing like what new passport means, what is

116
00:07:50,900 --> 00:07:54,170
cookies, what is sessions and what do you mean by serialize?

117
00:07:54,170 --> 00:07:55,580
And do you see that as an all those things?

118
00:07:56,600 --> 00:08:02,850
So with this, we are completing the cookies and sessions now, the final part of our web pages, Google

119
00:08:02,900 --> 00:08:10,340
authentication, how to use the Google servers to store the passports in their database and then access

120
00:08:10,790 --> 00:08:15,740
give the user a choice of logging in with his Google or Facebook account.

121
00:08:16,340 --> 00:08:19,260
It is basically all 2.0 will see that in the next.

122
00:08:20,060 --> 00:08:21,240
That's it for this video.

123
00:08:21,260 --> 00:08:21,650
Thank.
