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');
        }
      })
    }
  }
))

module.exports = passport;

@@ -170,17 +170,17 @@
 var 
-A
+a
 dapter =
  req
@@ -175,16 +175,20 @@
 dapter =
+ new
  require
@@ -230,35 +230,8 @@
 R'))
-;%0Avar adapter = new Adapter
 ();%0A
@@ -511,17 +511,16 @@
 %7D else %7B
- 
 %0A      a
@@ -595,16 +595,26 @@
  (err) %7B
+%0A         
  return 
@@ -623,16 +623,25 @@
 ne(err) 
+%0A        
 %7D%0A      
@@ -735,16 +735,29 @@
 ash)) %7B 
+%0A            
 return d
@@ -773,16 +773,27 @@
  false) 
+%0A          
 %7D%0A      

reformat for readability