Bird
0
0

What will happen if the JwtStrategy validate method returns null?

medium📝 component behavior Q5 of 15
NestJS - Authentication
What will happen if the JwtStrategy validate method returns null?
AAn error is thrown crashing the app
BUser is authenticated with empty data
CAuthentication fails and access is denied
DThe token is refreshed automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand validate method return effect

    Returning null means the user is not validated, so authentication fails.
  2. Step 2: Consequence of failed authentication

    Access is denied because the user is not authenticated; no token refresh or crash occurs.
  3. Final Answer:

    Authentication fails and access is denied -> Option C
  4. Quick Check:

    Null return = Authentication failure [OK]
Quick Trick: Return null in validate() to reject authentication [OK]
Common Mistakes:
  • Assuming null returns empty user data
  • Expecting automatic token refresh
  • Thinking app crashes on null

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes