AuthServiceProvider.php 903 Bytes
Newer Older
1
2
3
4
<?php

namespace App\Providers;

Jacob Priddy's avatar
Jacob Priddy committed
5
6
use App\Guards\ApiGuard;
use Illuminate\Support\Facades\Auth;
Jacob Priddy's avatar
Jacob Priddy committed
7
use Source\UseCases\Token\Authenticate\AuthenticateUseCase;
8
9
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

Jacob Priddy's avatar
Jacob Priddy committed
10
class AuthServiceProvider extends ServiceProvider {
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        // 'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
25
    public function boot() {
26
27
        $this->registerPolicies();

Jacob Priddy's avatar
Jacob Priddy committed
28
29
30
31
        // Define guard for the api
        Auth::extend(
            'api',
            static function ($app, $name, array $config) {
Jacob Priddy's avatar
Jacob Priddy committed
32
                return new ApiGuard($app->make(AuthenticateUseCase::class), $app['request']);
Jacob Priddy's avatar
Jacob Priddy committed
33
34
            }
        );
35
36
    }
}