Project Challenge: Retrieving a User at Login

In this challenge, we will be modifying the login function to retrieve an inserted user from the database.

We'll cover the following

Problem statement #

In this challenge, we will modify the login method so that it retrieves the required user from the database instead of searching in the list.

📌 Note: we have already inserted one user in the database for you. This is the admin user. You can see the insertion on lines 31 to 41. You can use this user to test out the modified login method.

You will perform the following tasks:

  1. Modify the login method to check for the user in the database and then authenticate it.

  2. Next, instead of storing the user object in the session, only store the id of the user in the session.

Get hands-on with 1200+ tech skills courses.