OAuthServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PHPHub\Providers;
4
5
use Auth;
6
use Dingo\Api\Auth\Auth as DingoAuth;
7
use Dingo\Api\Auth\Provider\OAuth2;
8
use Illuminate\Support\ServiceProvider;
9
use PHPHub\User;
10
11
class OAuthServiceProvider extends ServiceProvider
12
{
13
    public function boot()
14
    {
15
        $this->app[DingoAuth::class]->extend('oauth', function ($app) {
16
            $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker());
17
18
            $provider->setUserResolver(function ($id) {
19
                Auth::loginUsingId($id);
20
21
                return User::findOrFail($id);
22
            });
23
24
            $provider->setClientResolver(function ($id) {
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
                //TODO: Logic to return a client by their ID.
26
            });
27
28
            return $provider;
29
        });
30
    }
31
32
    public function register()
33
    {
34
        //
35
    }
36
}
37