0
0
Expressframework~5 mins

User login flow in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of a user login flow in an Express app?
To verify a user's identity by checking their credentials and then allowing access to protected parts of the app.
Click to reveal answer
beginner
Which Express middleware is commonly used to parse form data sent by a login form?
The express.urlencoded() middleware parses URL-encoded form data so you can access it via req.body.
Click to reveal answer
intermediate
Why do we use sessions or tokens after a user logs in?
To remember the user’s login state across different pages or requests without asking them to log in again each time.
Click to reveal answer
intermediate
What is the role of password hashing in a login flow?
Password hashing securely transforms the password so it’s not stored in plain text, protecting user data if the database is compromised.
Click to reveal answer
intermediate
In Express, how do you protect routes so only logged-in users can access them?
By creating middleware that checks if the user is authenticated before allowing access to the route, redirecting or blocking if not.
Click to reveal answer
Which method in Express is used to handle POST requests from a login form?
Aapp.listen()
Bapp.get()
Capp.use()
Dapp.post()
What does req.body contain in a login route?
AResponse data sent to the user
BUser input data from the login form
CSession information
DURL parameters
Why should passwords be hashed before storing in the database?
ATo keep passwords secret even if the database is leaked
BTo make passwords easier to read
CTo speed up login
DTo allow password recovery
What is a common way to keep a user logged in across multiple requests?
AUsing GET requests only
BRequiring login on every page
CUsing sessions or tokens
DStoring password in cookies
Which middleware can you use to protect routes in Express?
ACustom middleware that checks authentication
Bexpress.static()
Cexpress.json()
Dcors()
Describe the steps involved in a typical user login flow in an Express app.
Think about what happens from form submission to access granted.
You got /6 concepts.
    Explain how you would protect a route so only logged-in users can access it in Express.
    Focus on middleware role and checking user state.
    You got /4 concepts.