From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Optimizing session storage - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Optimizing session storage
In this lecture, we are going to further optimize the session storage for the cookies. Currently, we are dealing with a major flaw and that is when an invalid user credential is filled, the session gets created for a non registered user. Although the user does not get logged in for being an invalid user, still the session is created. And that data also gets stored inside the database. So we are going to fix this issue and only generate sessions for the registered users. And the final output would look like this for the invalid username and for the password. So inside the post login route, where we are checking for valid users, I'll add a custom property to the session that is username and another property for the message. Let's first define these two properties inside the session class of the declaration file. So here below is logged in, I'll give the username and message properties of type string. And I'll assign the username to the session username to store the username value…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Section introduction2m 33s
-
(Locked)
Setting up the sign-up route2m 24s
-
(Locked)
Designing the sign-up form2m 53s
-
(Locked)
Implementing show/hide password functionality4m 40s
-
(Locked)
Validating password2m 32s
-
(Locked)
Registering user to the database6m 50s
-
(Locked)
Configuring login page2m 12s
-
(Locked)
Validating user and sending cookie4m 41s
-
(Locked)
Reading a cookie2m 13s
-
(Locked)
Rendering DOM based on login status3m 48s
-
(Locked)
Implementing logout1m 20s
-
(Locked)
Configuring Express-Session2m 54s
-
(Locked)
Sending and reading session cookie3m 40s
-
(Locked)
Storing sessions in MySQL3m 44s
-
(Locked)
Destroying the session: Logout1m 42s
-
(Locked)
Optimizing session storage4m 15s
-
(Locked)
Implementing JWT token6m 51s
-
(Locked)
Validating request with middleware5m
-
(Locked)
Conditional rendering with token6m 14s
-
(Locked)
Hashing the password on sign-up3m 51s
-
(Locked)
Validating login credentials2m 15s
-
(Locked)
Finalizing MyStore application4m 20s
-
(Locked)
-
-