Skip to content

Instantly share code, notes, and snippets.

@ssi-anik
Last active February 21, 2021 09:05
Show Gist options
  • Select an option

  • Save ssi-anik/9258b453b1bb4bef07c8a01b56182a96 to your computer and use it in GitHub Desktop.

Select an option

Save ssi-anik/9258b453b1bb4bef07c8a01b56182a96 to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use App\Extensions\AccessTokenGuard;
use App\Extensions\TokenToUserProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Auth;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
* @return void
*/
public function boot () {
$this->registerPolicies();
Auth::extend('access_token', function ($app, $name, array $config) {
// automatically build the DI, put it as reference
$userProvider = app(TokenToUserProvider::class);
$request = app('request');
return new AccessTokenGuard($userProvider, $request, $config);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment