Bird
0
0

You want to customize the username field to 'email' in your LocalStrategy. How should you modify the constructor?

hard📝 Application Q8 of 15
NestJS - Authentication
You want to customize the username field to 'email' in your LocalStrategy. How should you modify the constructor?
Aconstructor(private authService: AuthService) { super({ field: 'email' }); }
Bconstructor(private authService: AuthService) { super({ username: 'email' }); }
Cconstructor(private authService: AuthService) { super({ usernameField: 'email' }); }
Dconstructor(private authService: AuthService) { super({ emailField: 'username' }); }
Step-by-Step Solution
Solution:
  1. Step 1: Know the correct option key

    The Passport local strategy expects usernameField to specify the username input field.
  2. Step 2: Match option key and value

    Setting usernameField: 'email' tells the strategy to use 'email' instead of 'username'.
  3. Final Answer:

    constructor(private authService: AuthService) { super({ usernameField: 'email' }); } -> Option C
  4. Quick Check:

    Use usernameField option to rename username input [OK]
Quick Trick: Use usernameField option to rename username input [OK]
Common Mistakes:
  • Using wrong option keys like field or emailField
  • Swapping key and value
  • Not passing options to super()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes