public function beforeFilter() { parent::beforeFilter(); $this->_checkAuth(); //Собственный фин. проект $this->loadModel('FinanceProject'); $this->loadModel('Group'); $this->loadModel('GroupMember'); $conditions = array('FinanceProject.user_id' => $this->currUserID, 'FinanceProject.name' => 'My finances'); $ownProject = $this->FinanceProject->find('first', compact('conditions')); if (!$ownProject) { $data['FinanceProject'] = array('name' => 'My finances', 'user_id' => $this->currUserID, 'hidden' => '0'); $this->FinanceProject->addProject($this->currUserID, $data); $ownProject = $this->FinanceProject->find('first', compact('conditions')); } //Собственный фин. счёт $this->loadModel('FinanceAccount'); $conditions = array('FinanceAccount.project_id' => Hash::get($ownProject, 'FinanceProject.id'), 'FinanceAccount.name' => 'My account'); $ownAccount = $this->FinanceAccount->find('first', compact('conditions')); if (!$ownAccount) { $data = array(); $data['FinanceAccount'] = array('name' => 'My account', 'project_id' => Hash::get($ownProject, 'FinanceProject.id'), 'currency' => 'USD', 'type' => '0', 'balance' => '0'); $this->FinanceAccount->addAccount($data); } $conditions = array('Group.owner_id' => $this->currUserID, 'Group.title' => 'My group'); $ownGroup = $this->Group->find('first', compact('conditions')); if (!$ownGroup) { $group = array('title' => 'My group', 'descr' => '', 'owner_id' => $this->currUserID, 'finance_project_id' => Hash::get($ownProject, 'FinanceProject.id'), 'hidden' => 1, 'video_url' => '', 'cat_id' => 33); if ($this->Group->save($group)) { $groupMember = array('group_id' => $this->Group->id, 'user_id' => $this->currUserID, 'approved' => $this->currUserID, 'sort_order' => 1, 'show_main' => 1, 'approve_date' => 1, 'approve_date' => date('Y-m-d H:i:s')); $this->GroupMember->save($groupMember); } } }
public function beforeFilter() { parent::beforeFilter(); $this->_checkAuth(); $this->set('balance', $this->User->getBalance($this->currUserID)); $this->set('PU_', '$'); $this->set('_PU', ''); }
public function beforeFilter() { parent::beforeFilter(); $this->layout = 'ajax'; JWT::$leeway = 5; // $leeway in seconds try { $token = JWT::decode($this->request->header('Server-Token'), Configure::read('Autobahn.key'), array('HS256')); } catch (Exception $e) { throw new ForbiddenException('Could not auth your request'); } $this->loadModel('User'); if (!isset($token->userId) || !$this->User->exists($token->userId)) { throw new ForbiddenException('Could not auth your request or user does not exists'); } $this->currUserID = $token->userId; $this->currUser = $this->User->findById($token->userId); $this->Auth->login($this->currUser['User']); if ($this->Auth->loggedIn()) { $this->_initTimezone($this->currUser['User']['timezone']); $this->_initLang($this->currUser['User']['lang']); $this->Auth->allow('*'); } }
public function beforeFilter() { parent::beforeFilter(); $this->_checkAuth(); }
public function beforeFilter() { parent::beforeFilter(); $this->_checkAuth(); $this->Auth->allow(array('switchLang')); }
public function beforeFilter() { parent::beforeFilter(); //$this->Auth->allow(array('settings')); }