var serializeError = Meteor.npmRequire('serialize-error');
var eveonlinejs = Meteor.npmRequire('eveonlinejs');
eveonlinejs.setCache(new eveonlinejs.cache.MemoryCache());

Meteor.methods({
  'validateKey': function validateKey (keyID, vCode) {
    validationResult = Async.runSync(function(done) {
      eveonlinejs.fetch('account:APIKeyInfo', {keyID: keyID, vCode: vCode}, function (err, result) {

        if (err) {
          if (err.response && err.response.statusCode !== 200) {
            switch (err.response.statusCode) {
              case 403:
                return done(null, {'ok': false, 'reason': 'Key is expired or invalid.'});
              default:
                return done(err, {'ok': false, 'reason': 'Connection error.', 'error': serializeError(err)});
            }
          } else {
            return done(err, {'ok': false, 'reason': 'Internal error.', 'error': serializeError(err)});
          }
        }

        if (result.type !== 'Account') return done(null, {'ok': false, 'reason': 'Key does not include all characters.'});
        if (result.accessMask !== '1073741823') return done(null, {'ok': false, 'reason': 'Access mask ' + result.accessMask + ' does not provide full access.'});
        if (result.expires !== '') return done(null, {'ok': false, 'reason': 'Key will expire ' + result.expires});
        done(null, {'ok': true, 'reason': 'Key has passed all validation checks.'});
      });
    });

    return validationResult;
  }
});

@@ -390,16 +390,76 @@
 esult) %7B
+%0A        var validationStatus = %7B'ok': null, 'reasons': %5B%5D%7D;
 %0A%0A      
@@ -658,27 +658,29 @@
 lse, 'reason
+s
 ': 
+%5B
 'Key is expi
@@ -695,16 +695,17 @@
 nvalid.'
+%5D
 %7D);%0A    
@@ -777,19 +777,21 @@
  'reason
+s
 ': 
+%5B
 'Connect
@@ -793,32 +793,33 @@
 nnection error.'
+%5D
 , 'error': seria
@@ -919,19 +919,21 @@
  'reason
+s
 ': 
+%5B
 'Interna
@@ -941,16 +941,17 @@
  error.'
+%5D
 , 'error
@@ -1042,50 +1042,89 @@
 t') 
-return done(null, %7B'ok': false, 'reason': 
+%7B%0A          validationStatus.ok = false;%0A          validationStatus.reasons.push(
 'Key
@@ -1157,20 +1157,29 @@
 acters.'
-%7D
 );%0A
+        %7D%0A
         
@@ -1222,50 +1222,89 @@
 3') 
-return done(null, %7B'ok': false, 'reason': 
+%7B%0A          validationStatus.ok = false;%0A          validationStatus.reasons.push(
 'Acc
@@ -1368,20 +1368,29 @@
 access.'
-%7D
 );%0A
+        %7D%0A
         
@@ -1419,51 +1419,88 @@
  '')
- return done(null, %7B'ok': false, 'reason': 
+%0A          validationStatus.ok = false;%0A          validationStatus.reasons.push(
 'Key
@@ -1530,17 +1530,16 @@
 .expires
-%7D
 );%0A     
@@ -1545,42 +1545,120 @@
     
-done(null, %7B'ok': true, '
+if (validationStatus.ok != false) %7B%0A          validationStatus.ok = true;%0A          validationStatus.
 reason
-': 
+s = %5B
 'Key
@@ -1692,17 +1692,65 @@
 checks.'
-%7D
+%5D;%0A        %7D%0A%0A        done(null, validationStatus
 );%0A     

Add multiple verification failure reasons on a single key