1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-18 01:58:25 +08:00
2021-02-13 18:21:42 +08:00

51 lines
980 B
PHP

<?php
namespace App\Http\Api\Controllers;
use App\Models\User as UserModel;
use App\Services\Auth\Api as ApiAuth;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller
{
/**
* @var UserModel
*/
protected $authUser;
use ResponseTrait;
use SecurityTrait;
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
if ($this->request->getHeader('Origin')) {
$this->setCors();
}
$this->checkRateLimit();
return true;
}
public function initialize()
{
$this->authUser = $this->getAuthUser();
$this->eventsManager->fire('Site:afterView', $this, $this->authUser);
}
protected function getAuthUser()
{
/**
* @var ApiAuth $auth
*/
$auth = $this->getDI()->get('auth');
return $auth->getCurrentUser();
}
}