public function createuserAction() { $t = Doctrine::getTable('User_Model_User'); try { $c = $t->count(); if ($c > 0) { $this->_helper->redirector->gotoSimple('success', 'install', 'install'); } else { $this->view->form = new Install_Form_InstallUser(); if ($this->request->isPost()) { if ($this->view->form->isValid($_POST)) { $values = $this->view->form->getValues(); $user = new User_Model_User(); $user->name = $values['username']; $user->setPassword($values['password1']); $user->email = $values['email']; $user->save(); $ur = new User_Model_Role(); $ur->User_Model_User = $user; $ur->role_name = 'admin_admin'; $ur->save(); $this->_helper->redirector->gotoSimple('success', 'install', 'install'); } } } } catch (Doctrine_Exception $e) { $this->_helper->redirector->gotoSimple('index', 'install', 'install'); } }
public function connectAction() { $form = new User_Form_Login(); if( $this->getRequest()->isPost() ) { if( $form->isValid( $this->getRequest()->getPost() ) ){ $user = new User_Model_User(); $user->setLogin($form->getValue('login') ); $user->setPassword($form->getValue('password') ); $userMapper = new User_Model_Mapper_User(); if( $id = $userMapper->login( $user ) ){ $this->addSystemSuccess('connexion'); $this->_redirect( $this->_helper->url->url( array(), 'userList' )); } else { $this->addSystemError('Echec connexion'); } } else { $this->addSystemError('echec connexion'); } } $this->view->form = $form; }