You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Providers;
use App\Fingerprint; use App\Utilities\RequestMixin; use App\Utilities\BusinessInfoRequestMixin; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider { /** * The policy mappings for the application. * * @var array */ protected $policies = [ // 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies();
$this->app['request']->mixin(new RequestMixin); $this->app['request']->mixin(new BusinessInfoRequestMixin);
$this->app['auth']->viaRequest('api', function ($request) { if ($request->bearerToken() === null) { return null; }
$fingerprint = Fingerprint::where([ 'token' => $request->bearerToken(), 'agent' => $request->getAgent(), 'os' => $request->getOS(), ])->first();
return $fingerprint->user->setAttribute('token', $fingerprint->token); }); } }
|