-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
315 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Gzero\Core\Menu\Link; | ||
use Gzero\Core\Menu\Register; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class ComposerServiceProvider extends ServiceProvider { | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
view()->composer( | ||
'account.menu', | ||
function ($view) { | ||
$menu = app('gzero.menu.account'); | ||
/** @var $menu Register */ | ||
$menu->add(new Link(route('account'), trans('user.my_account'), 100)); | ||
$menu->add(new Link(route('account.oauth'), trans('user.oauth'), 200)); | ||
$view->with('menu', $menu->getMenu()); | ||
} | ||
); | ||
|
||
view()->composer( | ||
'includes.disqus.disqus', | ||
function ($view) { | ||
$data = []; | ||
$user = auth()->user(); | ||
if (!$user->isGuest()) { | ||
$data = [ | ||
"id" => $user["id"], | ||
"username" => $user->getPresenter()->displayName(), | ||
"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"); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.