Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
In passport.js, middleware method "local-signup" have unique key email and password. Can be changed or not

Here the code is

passport.use('local-signup', new LocalStrategy({
    usernameField : 'email',
    passwordField : 'password',
    passReqToCallback : true 
},
function(req, email, password, done) {
    console.log("email==" + email + "   " + "password==" + password);
    User.findOne({ 'email' :  email }, function(err, user) {
        if (err)
            return done(err);
        if (user) {
            return done(null, false, req.flash('signupMessage', 'That email is already taken.'));
        } else {
            var newUser = new User();
            newUser.email    = email;
            newUser.password = newUser.generateHash(password);
            newUser.save(function(err) {
                if (err)
                    throw err;
                return done(null, newUser);
            });
        }

    });    
   
}));

My question is

Can We changed value of usernameField and passwordField?

As usernameField and passwordField keys never be changed because it is predifned keys in passport library.

passport.use('local-signup', new LocalStrategy({
 usernameField : 'emailId',
 passwordField : 'paswrd',
 passReqToCallback : true 
},
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Can We changed value of usernameField and passwordField?

Yes. It's even documented!

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!