"use strict";

var db = require('../models');

var verify = {};

/**
 * Remove "Bearer " if headerLine contains it. otherwise return the original headerLine
 *
 * @param headerLine
 * @returns {*}
 */

var extractToken = function(headerLine) {
  if (headerLine.indexOf("Bearer ") === 0) {
    return headerLine.substr(7);
  } else {
    return headerLine;
  }
};


/**
 * Check if the access token is valid
 *
 * @param requestToken
 * @param clientId
 * @param callback
 *  Returns if authenticated via : callback(err, accessToken, client)
 *  if not, accessToken === false and client === false
 */

verify.accessToken = function(requestToken, clientId, callback) {

  requestToken = extractToken(requestToken);

  db.AccessToken.find(requestToken).complete(function(err, accessToken) {
    if (err || !accessToken) {
      callback(err, false, false);
    } else {

      accessToken.getClient({ where: { 'id' : clientId } }).complete(function(err, client) {
        if (err || !client) {
          callback(err, false, false);
        } else {
          callback(err, accessToken, client);
        }
      });

    }
  });

};


module.exports = verify;
@@ -828,36 +828,34 @@
 llback(err, 
-false, false
+null, null
 );%0A    %7D els
@@ -1010,20 +1010,18 @@
 rr, 
-false, false
+null, null
 );%0A 

Fix return values