-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppServiceProvider.php
97 lines (88 loc) · 2.86 KB
/
AppServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php namespace App\Providers;
use Gzero\Core\AbstractServiceProvider;
class AppServiceProvider extends AbstractServiceProvider {
/**
* List of additional providers
*
* @var array
*/
protected $providers = [
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
];
/**
* List of service providers aliases
*
* @var array
*/
protected $aliases = [
'Debugbar' => 'Barryvdh\Debugbar\Facade'
];
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
view()->composer(
'includes.disqus.disqus',
function ($view) {
$data = [];
$user = auth()->user();
if ($user) {
$data = [
"id" => $user["id"],
"username" => $user["firstName"] . ' ' . $user["lastName"],
"email" => $user["email"],
//"avatar" => $user["avatar"],
];
}
function dsq_hmacsha1($data, $key)
{
$blockSize = 64;
if (strlen($key) > $blockSize) {
$key = pack('H*', sha1($key));
}
$key = str_pad($key, $blockSize, chr(0x00));
$ipad = str_repeat(chr(0x36), $blockSize);
$opad = str_repeat(chr(0x5c), $blockSize);
$hmac = pack(
'H*',
sha1(
($key ^ $opad) . pack(
'H*',
sha1(
($key ^ $ipad) . $data
)
)
)
);
return bin2hex($hmac);
}
$message = base64_encode(json_encode($data));
$timestamp = time();
$hmac = dsq_hmacsha1($message . ' ' . $timestamp, config('disqus.api_secret'));
$view->with('remoteAuthS3', "$message $hmac $timestamp");
}
);
}
/**
* Register any application services.
*
* This service provider is a great spot to register your various container
* bindings with the application. As you can see, we are registering our
* "Registrar" implementation here. You can add your own bindings too!
*
* @return void
*/
public function register()
{
$this->registerAdditionalProviders();
$this->registerProvidersAliases();
$this->app->bind(
'Illuminate\Contracts\Auth\Registrar',
'App\Services\Registrar'
);
}
}