Skip to content

Commit

Permalink
formatting and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 31, 2020
1 parent ac21f30 commit fe28ab2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions config/scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@

/*
|--------------------------------------------------------------------------
| Auto Identify User
| Identify User
|--------------------------------------------------------------------------
|
| This option allows you to control whether to automatically
| identify the currently authenticated user with a search
| engine that is supported. By default it's turned off.
| This option allows you to control whether to notify the search engine
| of the user performing the search. This is sometimes useful if the
| engine supports any analytics based on this application's users.
|
| Supported engines: "algolia"
|
*/

'identify_user' => env('SCOUT_IDENTIFY_USER', false),
'identify' => env('SCOUT_IDENTIFY', false),

/*
|--------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions src/EngineManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,25 @@ protected function ensureAlgoliaClientIsInstalled()
}

/**
* Set the default Algolia config headers.
* Set the default Algolia configuration headers.
*
* @return array
*/
protected function defaultAlgoliaHeaders()
{
if (! config('scout.identify_user')) {
if (! config('scout.identify')) {
return [];
}

$headers = [];

if (
! config('app.debug') &&
if (! config('app.debug') &&
filter_var($ip = request()->ip(), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)
) {
$headers['X-Forwarded-For'] = $ip;
}

if ($user = request()->user()) {
if ($user = request()->user() && method_exists($user, 'getKey')) {
$headers['X-Algolia-UserToken'] = $user->getKey();
}

Expand Down

0 comments on commit fe28ab2

Please sign in to comment.