Skip to content

Commit

Permalink
Merge pull request #94 from sashahilton00/master
Browse files Browse the repository at this point in the history
Fix X-Authorization Error
  • Loading branch information
awkwardusername committed Feb 9, 2016
2 parents d76e382 + 0d1a64a commit eeb59f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Http/Middleware/ApiGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,22 @@ public function handle($request, Closure $next, $serializedApiMethods=null)

// login User
$headers = apache_request_headers();
$api_key = $headers[Config::get('apiguard.keyName', 'X-Authorization')];
//$api_key = $headers[Config::get('apiguard.keyName', 'X-Authorization')];

if (empty($headers[Config::get('apiguard.keyName', 'X-Authorization')])) {
$api_key = null;
} else {
$api_key = $headers[Config::get('apiguard.keyName', 'X-Authorization')];
}

if(!empty($api_key)) {

$user_id = App::make(Config::get('apiguard.model', 'Chrisbjr\ApiGuard\Models\ApiKey'))->where('key', $api_key)
->pluck('user_id');

if($user_id !== 0)
Auth::loginUsingId($user_id);

}
return $next($request);
}
}

0 comments on commit eeb59f2

Please sign in to comment.