<commit_before>var passport = require('passport');
var BasicStrategy = require("passport-http").BasicStrategy;
var utils = require("../lib/utils");
var nconf = require('./nconf.js');

var Adapter = require(nconf.get('RIPPLE_DATAMODEL_ADAPTER'));
var adapter = new Adapter();

passport.use(new BasicStrategy(
  function(username, password, done) {
    if (username == 'admin') {
      if (password && (password == nconf.get('KEY'))) {
        return done(null, { admin: true }); 
      } else {
        return done('Invalid admin key');
      }
    } else { 
      adapter.getUser({ name: username }, function(err, user) { 
        if (err) { return done(err) }
        if (user) { 
          if (!utils.verifyPassword(password, user.salt, user.password_hash)) { return done(null, false) }
          return done(null, user);
        } else {
          adapter.createUser({ name: username, password: password }, function(err, user) {
            // if there are no errors, allow addtional logic to be executed
            return err ? done(err, user) : done(null, user);
          });
        }
      })
    }<commit_msg>[FEATURE] Remove user creation from passport functionality.<commit_after>var passport = require('passport');
var BasicStrategy = require("passport-http").BasicStrategy;
var utils = require("../lib/utils");
var nconf = require('./nconf.js');

var Adapter = require(nconf.get('RIPPLE_DATAMODEL_ADAPTER'));
var adapter = new Adapter();

passport.use(new BasicStrategy(
  function(username, password, done) {
    if (username == 'admin') {
      if (password && (password == nconf.get('KEY'))) {
        return done(null, { admin: true }); 
      } else {
        return done('Invalid admin key');
      }
    } else { 
      adapter.getUser({ name: username }, function(err, user) { 
        if (err) { return done(err) }
        if (user) { 
          if (!utils.verifyPassword(password, user.salt, user.password_hash)) { return done(null, false) }
          return done(null, user);
        } else {
          return done('invalid credentials');
        }
      })
    }
{'fraction_non_alphanumeric': 0.14990421455938696, 'fraction_numerical': 0.0, 'mean_word_length': 2.7844202898550723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1310270', 'n_tokens_mistral': 616, 'n_tokens_neox': 601, 'n_words': 159}