1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 20:00:27 +08:00
2020-08-22 19:47:57 +08:00

52 lines
1018 B
PHP

<?php
namespace App\Http\Desktop\Controllers;
use App\Models\User as UserModel;
use App\Services\Auth\Desktop as DesktopAuth;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Mvc\Dispatcher;
class LayerController extends \Phalcon\Mvc\Controller
{
/**
* @var UserModel
*/
protected $authUser;
use ResponseTrait;
use SecurityTrait;
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
if ($this->isNotSafeRequest()) {
$this->checkHttpReferer();
$this->checkCsrfToken();
}
$this->checkRateLimit();
return true;
}
public function initialize()
{
$this->authUser = $this->getAuthUser();
$this->view->setVar('auth_user', $this->authUser);
}
protected function getAuthUser()
{
/**
* @var DesktopAuth $auth
*/
$auth = $this->getDI()->get('auth');
return $auth->getCurrentUser();
}
}