<commit_before>var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var mongoose = require('mongoose');

module.exports = function () {
  passport.use(new LocalStrategy({
    usernameField: 'userName',
    passwordField: 'password'
  },
  function (username, password, done) {
  // To Jeffy: Implement Moongose Below:
  //======================================================================
    // var url;
    // mongoose.connect(url, function(err, db) {
    //   var collection = db.collection('users');
    //   collection.findOne({username: username}, function(err, results) {
        if (username === "admin" && password === "<PASSWORD>") {
          return done(null, {name: "admin"});
        }

        return done(null, false, { message: 'Incorrect username.' });
      }));
  //   });
  // }));
  //======================================================================

};<commit_msg>(feature) builds login routes<commit_after>var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;

// User Model
var User = require('../../models/user.server.model.js');
//possibly refactor to use userCtrl later - need verifyUser method
//var userCtrl = require('../../controllers/user.server.controller');

module.exports = function () {

  passport.use(new LocalStrategy(
    function(username, password, done) {
      User.findOne({ userName: username })
        .exec(function(err, user) {
          if (user===null) {
            console.log("User profile does not exist.");
            return done(null, false, { message: 'Incorrect username.' });
          } else if (err) {
            var errMsg = 'Sorry, there was an error locating your user profile ' + err;
                console.log(errMsg);
          } else if (user.password === password) {
            console.log("login success!");
            return done(null, {name: user.userName});
          }
        });
    }
  ));
};
{'fraction_non_alphanumeric': 0.22126144455747712, 'fraction_numerical': 0.0, 'mean_word_length': 2.973737373737374, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '812945', 'n_tokens_mistral': 526, 'n_tokens_neox': 516, 'n_words': 130}