Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

passport-local strategy

passport.use(new LocalStrategy(
  // function of username, password, done(callback)
  function(username, password, done) {
    // look for the user data
    User.findOne({ username: username }, function (err, user) {
      // if there is an error
      if (err) { return done(err); }
      // if user doesn't exist
      if (!user) { return done(null, false, { message: 'User not found.' }); }
      // if the password isn't correct
      if (!user.verifyPassword(password)) { return done(null, false, {   
      message: 'Invalid password.' }); }
      // if the user is properly authenticated
      return done(null, user);
    });
  }
));
Comment

passport local strategy

passport.use(new LocalStrategy(
  function(username, password, done) {
    User.findOne({ username: username }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(password)) { return done(null, false); }
      return done(null, user);
    });
  }
));
Comment

passport-local strategy

passport.use(new LocalStrategy(
  // function of username, password, done(callback)
  function(username, password, done) {
    // look for the user data
    User.findOne({ username: username }, function (err, user) {
      // if there is an error
      if (err) { return done(err); }
      // if user doesn't exist
      if (!user) { return done(null, false, { message: 'User not found.' }); }
      // if the password isn't correct
      if (!user.verifyPassword(password)) { return done(null, false, {   
      message: 'Invalid password.' }); }
      // if the user is properly authenticated
      return done(null, user);
    });
  }
));
Comment

PREVIOUS NEXT
Code Example
Javascript :: new useSelector 
Javascript :: npm ERR! missing script: build:dev 
Javascript :: fs.readfilesync withFileTypes true 
Javascript :: JavaScript is case-sensitive 
Javascript :: edit message sent by discord.js 
Javascript :: react-native-vector-icons 
Javascript :: local 
Javascript :: new file shortcut vscode 
Javascript :: javascript prototype inheritance 
Javascript :: eventlistener javascript 
Javascript :: what is a blob in javascript 
Javascript :: excel json to table 
Javascript :: status discored jks 
Javascript :: node red push to array 
Javascript :: react and node js sample project github 
Javascript :: node.js server-side javascript 
Javascript :: can we send image in json in angular 
Javascript :: discord js get specific user from users 
Javascript :: angular ngbtooltip z-index 
Javascript :: axios get request with nested params serialize qs 
Javascript :: random order of buttons on refresh in vanilla js 
Javascript :: JS urdsathdzygo8sdhurj.hdo78suij 
Javascript :: node alternative to btoa 
Javascript :: moment get end of next moenth 
Javascript :: blazor sample ujsing cliam policy 
Javascript :: string literals javascript 
Javascript :: measure width in px chrome extension 
Javascript :: how to install reveal.js from node 
Javascript :: cuando usar for en js 
Javascript :: how to add class to element on mouseclick with js 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =