// Terminal call: node server/ldap_test.js - needs VPN or eduroam
const inquirer  = require('inquirer'),
      ldap      = require('./server/ldap_ohm.js');

inquirer.prompt([
  {
    name: 'username',
    type: 'input',
    message: 'Enter your VirtuOhm username:',
    validate: function( value ) {
      if (value.length) {
        return true;
      } else {
        return 'Please enter your username.';
      }
    }
  },
  {
    name: 'password',
    type: 'password',
    message: 'Enter your password:',
    validate: function(value) {
      if (value.length) {
        return true;
      } else {
        return 'Please enter your password.';
      }
    }
  }])
  .then(answers => {
    ldap.init(null);
    ldap.authorize(answers.username,answers.password,function(user) {
        console.log(JSON.stringify(user));
        process.exit();
    });
  });

