1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* NOTICE OF LICENSE |
5
|
|
|
* |
6
|
|
|
* Part of the Rinvex Authy Package. |
7
|
|
|
* |
8
|
|
|
* This source file is subject to The MIT License (MIT) |
9
|
|
|
* that is bundled with this package in the LICENSE file. |
10
|
|
|
* |
11
|
|
|
* Package: Rinvex Authy Package |
12
|
|
|
* License: The MIT License (MIT) |
13
|
|
|
* Link: https://rinvex.com |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Rinvex\Authy\Providers; |
17
|
|
|
|
18
|
|
|
use Rinvex\Authy\App as AuthyApp; |
19
|
|
|
use Rinvex\Authy\User as AuthyUser; |
20
|
|
|
use GuzzleHttp\Client as HttpClient; |
21
|
|
|
use Rinvex\Authy\Token as AuthyToken; |
22
|
|
|
use Illuminate\Support\ServiceProvider; |
23
|
|
|
|
24
|
|
|
class AuthyServiceProvider extends ServiceProvider |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Indicates if loading of the provider is deferred. |
28
|
|
|
* |
29
|
|
|
* @var bool |
30
|
|
|
*/ |
31
|
|
|
protected $defer = true; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function register() |
37
|
|
|
{ |
38
|
|
|
$httpClient = new HttpClient(); |
39
|
|
|
$key = config('services.authy.secret'); |
40
|
|
|
|
41
|
|
|
$this->app->singleton('rinvex.authy.app', function ($app) use ($httpClient, $key) { |
|
|
|
|
42
|
|
|
return new AuthyApp($httpClient, $key); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
$this->app->singleton('rinvex.authy.user', function ($app) use ($httpClient, $key) { |
|
|
|
|
46
|
|
|
return new AuthyUser($httpClient, $key); |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
$this->app->singleton('rinvex.authy.token', function ($app) use ($httpClient, $key) { |
|
|
|
|
50
|
|
|
return new AuthyToken($httpClient, $key); |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
$this->app->alias('rinvex.authy.app', AuthyApp::class); |
54
|
|
|
$this->app->alias('rinvex.authy.user', AuthyUser::class); |
55
|
|
|
$this->app->alias('rinvex.authy.token', AuthyToken::class); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get the services provided by the provider. |
60
|
|
|
* |
61
|
|
|
* @return array |
|
|
|
|
62
|
|
|
*/ |
63
|
|
|
public function provides() |
64
|
|
|
{ |
65
|
|
|
return ['rinvex.authy.app', 'rinvex.authy.user', 'rinvex.authy.token']; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.