Recall & Review
beginner
What is the purpose of the Local strategy in NestJS authentication?
The Local strategy is used to authenticate users by verifying their username and password during login.
Click to reveal answer
beginner
Which NestJS package provides the Local strategy for username/password authentication?
The @nestjs/passport package provides the Local strategy by integrating Passport.js with NestJS.
Click to reveal answer
intermediate
In a Local strategy, what method is typically overridden to validate user credentials?
The validate() method is overridden to check the username and password against stored user data.
Click to reveal answer
intermediate
What does the validate() method return if the user credentials are correct?
It returns the user object without the password, which Passport attaches to the request object.
Click to reveal answer
intermediate
How does NestJS use the Local strategy in a login route?
NestJS uses the @UseGuards(AuthGuard('local')) decorator to protect the login route and trigger the Local strategy.
Click to reveal answer
What does the Local strategy in NestJS authenticate?
✗ Incorrect
The Local strategy is designed to authenticate users by verifying their username and password.
Which method do you override in a Local strategy to check user credentials?
✗ Incorrect
The validate() method is where you check the username and password against stored data.
What happens if validate() returns null or throws an error in Local strategy?
✗ Incorrect
If validate() returns null or throws, authentication fails and access is denied.
Which decorator applies the Local strategy guard to a route in NestJS?
✗ Incorrect
The @UseGuards(AuthGuard('local')) decorator applies the Local strategy guard.
What package must be installed to use Local strategy in NestJS?
✗ Incorrect
The @nestjs/passport package integrates Passport.js strategies including Local.
Explain how the Local strategy works in NestJS for username and password authentication.
Think about how NestJS checks user login details step by step.
You got /5 concepts.
Describe how to protect a login route using the Local strategy in NestJS.
Focus on the decorator and guard usage.
You got /4 concepts.