public function init() { /* Initialize action controller here */ $lm = MyLayoutManager::getInstance(); $lm->setLayoutFileName("backend.phtml"); $lm->setTitle('ระบบหลังบ้านจ้า'); $session = SessionDataModel::getInstance(); if ($this->getParam('action') != 'login') { $user = $session->getMyUser(); if ($user == null) { $url = '/manage/login'; $this->redirect($url); } } }
public function loginAction() { $username = $this->getRequest()->getParam('username'); $password = md5($this->getRequest()->getParam('password')); $user = MyEntityManagerFactory::getEntityManager()->getRepository("\\Models\\Entities\\User")->findOneBy(array('username' => $username, 'password' => $password)); $session = SessionDataModel::getInstance(); if ($user) { $session->setMyUser($user); } $url = '/manage/movies'; $this->redirect($url); }