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.
 
 

48 lines
1.2 KiB

<?php
namespace App\Providers;
use App\Models\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('token', function ($request) {
if ($request->bearerToken() === null) {
return null;
}
$fingerprint = Fingerprint::where([
'token' => $request->bearerToken(),
'agent' => $request->getAgent(),
'os' => $request->getOS(),
])->firstOrFail();
return $fingerprint->user->setAttribute('token', $fingerprint->token);
});
}
}