Skip to content

Commit

Permalink
Merge efb0a78 into 2104fbe
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSkierniewski committed Mar 22, 2017
2 parents 2104fbe + efb0a78 commit 2e7b757
Show file tree
Hide file tree
Showing 15 changed files with 315 additions and 119 deletions.
24 changes: 3 additions & 21 deletions app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,17 @@

use Illuminate\Http\Request;
use Gzero\Core\Controllers\BaseController;
use Gzero\Core\Menu\Register;

class AccountController extends BaseController {
/**
* @var Register
*/
protected $userMenu;

/**
* AccountController constructor.
*
* @param Register $userMenu
*/
public function __construct(Register $userMenu)
{
$this->userMenu = $userMenu;
$this->userMenu->addLink(route('account'), 'user.my_account');
$this->userMenu->addLink(route('account.oauth'), 'user.oauth');
}

public function account()
{
/**@TODO we need proper user menu method */
return view('account.index', ['menu' => $this->userMenu->getMenu()]);
return view('account.index');
}

public function edit()
{
return view('account.edit', ['menu' => $this->userMenu->getMenu()]);
return view('account.edit');
}

public function welcome(Request $request)
Expand All @@ -48,6 +30,6 @@ public function welcome(Request $request)

public function oauth()
{
return view('account.oauth', ['menu' => $this->userMenu->getMenu()]);
return view('account.oauth');
}
}
2 changes: 1 addition & 1 deletion app/Jobs/SendWelcomeEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(Mailer $mailer)
['user' => $this->user],
function ($m) {
$m->to($this->user->email, $this->user->name)
->subject(trans('emails.welcome.subject', ['siteName' => config('gzero.site_name')]));
->subject(trans('emails.welcome.subject', ['siteName' => config('app.name')]));
}
);
} catch (\Swift_TransportException $e) {
Expand Down
44 changes: 0 additions & 44 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,6 @@ function () {
}
);
}

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");
}
);
}

/**
Expand Down
72 changes: 72 additions & 0 deletions app/Providers/ComposerServiceProvider.php
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");
}
);
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"gzero/cms": "dev-master",
"gzero/api": "dev-master",
"gzero/admin": "dev-master",
"gzero/social": "dev-#61_fix_gzero_social",
"predis/predis": "^1.1",
"league/flysystem-aws-s3-v3": "^1.0"
},
Expand Down
Loading

0 comments on commit 2e7b757

Please sign in to comment.