title: nodes passport Error: Unknown authentication strategy "local-login"
body: <p>I have been trying to get local authentication work with passport on nodejs and as far as i can tell all of my code it is correct but i keep getting the same annoying error about "unknown authentication strategy so maybe someone else can help me with this problem my code is shown below.</p>
  
  <p>Here is my code for passport configuration in nodejs.</p>
  
  <pre><code>var passport = require('passport');
  var LocalStrategy = require('passport-local').Strategy;
  var User = require('../models/user');
  
  module.exports = function(passport) {
  
  
      passport.serializeUser(function(user, done) {
          done(null, user.id);
      });
  
      passport.deserializeUser(function(id, done) {
          User.findById(id, function(err, user) {
              done(err, user);
          });
      });
  
      passport.use('local-signup', new LocalStrategy({
  
          usernameField : 'username',
          passwordField : 'password',
          passReqToCallback : true
      },
  
      function(req, username, password, done) {
  
          process.nextTick(function() {
  
              User.findOne({ 'local.username' : username}, function(err, user) {
                  if (err)
                      return done(err);
  
                  if(user) {
                      return done(null, false, req.flash('signupMessage', 'That Username is already taken.'));
                  }
  
                  else {
  
                      var newUser = new User();
  
                      newUser.local.username = username;
                      newUser.local.password = newUser.generateHash(password);
  
  
                      newUser.save(function(err) {
                          if(err)
                              throw err;
  
                          return done(null, newUser);
                      });
                  }
              });
          });
      }));
  
  
  
      passport.use('local-login', new LocalStrategy({
  
          usernameField : 'username',
          passwordField : 'password',
          passReqToCallback : true
      },
      function(req, username, password,done) {
  
          User.findOne({ 'local.username' : username}, function(err, user) {
  
              if(err)
                  return done(err);
  
              if(!user)
                  return done(null, false, req.flash('loginMessage', 'No user found.'));
  
              if(!user.validPassword(password))
                  return done(null, false, req.flash('loginMessage', 'Oops! Wrong password.'));
  
              return done(null, user);
          });
      }));
  
  };
  </code></pre>
  
  <p>And here is the post on the server side.</p>
  
  <pre><code>app.post('/signin', passport.authenticate('local-login', {
      successRedirect : '/profile',
      failureRedirect : '/login',
      failureFlash : true
  }));
  </code></pre>
  
  <p>And here is the form in the html doc</p>
  
  <pre><code>&lt;div id="signin"&gt;
          &lt;form class="form-horizontal" method="POST" action="/signin"&gt;
              &lt;div class="form-group"&gt;
              &lt;label class="control-label col-sm-2"&gt;Username:&lt;/label&gt; 
              &lt;div class="col-xs-3"&gt;
                  &lt;input type="text" class="form-control"&gt;&lt;/input&gt;&lt;br&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
              &lt;label class="control-label col-sm-2"&gt;Password:&lt;/label&gt;
              &lt;div class="col-xs-3"&gt;
                  &lt;input type="password" class="form-control"&gt;&lt;/input&gt;&lt;br&gt;&lt;br&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
              &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                  &lt;button type="submit" class="btn btn-default btn-lg"&gt;Sign In&lt;/button&gt;&lt;br&gt;&lt;br&gt;
              &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  
          &lt;div id="accountlinks"&gt;
              &lt;a href="/signup"&gt;Create Account&lt;/a&gt;&lt;br&gt;
              &lt;a href=""&gt;Forgot Password&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Can anyone please help me by telling me what i have done wrong. thanks</p>