index.js
function requireAuthorization(handler) {
  return function(request, response, store, parameters) {
    var handlerArguments = arguments
    var publisher = parameters.publisher
    var authorization = request.headers.authorization
    if (authorization) {
      var parsed = parseAuthorization(authorization)
      if (parsed === false || parsed.user !== publisher) {
        respond401(response) }
      else {
        checkPassword(publisher, parsed.password, function(error, valid) {
          if (error) {
            respond500(request, response, error) }
          else {
            if (valid) {
              handler.apply(this, handlerArguments) }
            else {
              respond401(response) } } }) } }
    else {
      respond401(response) } } }
function requireAuthorization(handler) {
  return function(request, response, store, parameters) {
    var handlerArguments = arguments
    var publisher = parameters.publisher
    var authorization = request.headers.authorization
    if (authorization) {
      var parsed = parseAuthorization(authorization)
      if (parsed === false || parsed.user !== publisher) {
        respond401(response) }
      else {
        checkPassword(publisher, parsed.password, function(error, valid) {
          if (error) {
            respond500(request, response, error) }
          else {
            if (valid) {
              handler.apply(this, handlerArguments) }
            else {
              respond401(response) } } }) } }
    else {
      respond401(response) } } }
function requireAuthorization ( handler ) { return function ( request , response , store , parameters ) { var handlerArguments = arguments var publisher = parameters . publisher var authorization = request . headers . authorization if ( authorization ) { var parsed = parseAuthorization ( authorization ) if ( parsed === false || parsed . user !== publisher ) { respond401 ( response ) } else { checkPassword ( publisher , parsed . password , function ( error , valid ) { if ( error ) { respond500 ( request , response , error ) } else { if ( valid ) { handler . apply ( this , handlerArguments ) } else { respond401 ( response ) } } } ) } } else { respond401 ( response ) } } }
Wrap a request handler function to check authoriztion.
Wrap a request handler function to check authoriztion .