Completed
Push — api/develop ( 67b89b...086d67 )
by Bertrand
11:33 queued 57s
created

OAuthServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the HRis Software package.
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * Licensed under the 3-clause BSD License.
9
 *
10
 * This source file is subject to the 3-clause BSD License that is
11
 * bundled with this package in the LICENSE file.
12
 *
13
 * @version    alpha
14
 *
15
 * @author     Bertrand Kintanar <[email protected]>
16
 * @license    BSD License (3-clause)
17
 * @copyright  (c) 2014-2016, b8 Studios, Ltd
18
 *
19
 * @link       http://github.com/HB-Co/HRis
20
 */
21
22
namespace HRis\Providers;
23
24
use Dingo\Api\Auth\Auth;
25
use Dingo\Api\Auth\Provider\OAuth2;
26
use Illuminate\Support\ServiceProvider;
27
use Irradiate\Eloquent\User;
28
29
class OAuthServiceProvider extends ServiceProvider
30
{
31
    /**
32
     * Bootstrap any application services.
33
     *
34
     * @return void
35
     */
36 204
    public function boot()
37
    {
38
        $this->app[Auth::class]->extend('oauth', function ($app) {
39 204
            $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker());
40
41
            $provider->setUserResolver(function ($id) {
42
                return User::findOrFail($id);
43 204
            });
44
45 204
            $provider->setClientResolver(function ($id) {
46
                return User::findOrFail($id);
47 204
            });
48
49 204
            return $provider;
50 204
        });
51 204
    }
52
53
    /**
54
     * Register any application services.
55
     *
56
     * @return void
57
     */
58 204
    public function register()
59
    {
60
        //
61 204
    }
62
}
63