Esempio n. 1
0
 public function login()
 {
     if ($this->_router->isPostRequest()) {
         if ($_POST['login'] != '' && $_POST['passwd'] != '') {
             $db = Zend_Db_Table::getDefaultAdapter();
             // tworzymy instancję adaptera autoryzacji
             $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'cms_user', 'user_login', 'user_passwd');
             $authAdapter->setIdentity($_POST['login']);
             $authAdapter->setCredential(sha1($_POST['passwd']));
             // sprawdzamy, czy użytkownik jest aktywny
             $authAdapter->setCredentialTreatment("? AND user_active = '1'");
             // autoryzacja
             $result = $authAdapter->authenticate();
             if ($result->isValid()) {
                 $user_data = $authAdapter->getResultRowObject();
                 /*	zapisanie roli zalogowanego uzytkownika	*/
                 $this->_roles = RolesModel::Instance();
                 $role = $this->_roles->getRoleData($user_data->role_id);
                 $user_data->role_code = $role['role_code'];
                 $this->_storage->write($user_data);
                 // ustawienie ACL dla użytkownika
                 $this->_engine->addHttpHeader("Location: /" . $this->_router->getUrl('cms', 'index'));
             } else {
                 $this->_view->error = '1';
             }
         } else {
             $this->_view->error = '1';
         }
     }
     $this->_engine->setToRender('login.tpl');
 }
Esempio n. 2
0
 public function __construct($engine)
 {
     parent::__construct($engine);
     if (!$this->_auth->hasIdentity()) {
         $this->engine->addHttpHeader("Location: " . $this->router->getUrl('auth'));
         exit;
     }
     $this->_roles = RolesModel::Instance();
     $this->view->page_sidebar = $this->view->render('modules/role/sidebar.tpl');
 }