Example #1
0
 public function loginAction()
 {
     $userForm = new Form_User();
     $userForm->setAction('/user/login');
     $userForm->removeElement('first_name');
     $userForm->removeElement('last_name');
     $userForm->removeElement('role');
     if ($this->_request->isPost() && $userForm->isValid($_POST)) {
         $data = $userForm->getValues();
         //set up the auth adapter
         // get the default db adapter
         $db = Zend_Db_Table::getDefaultAdapter();
         //create the auth adapter
         $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password');
         //set the username and password
         $authAdapter->setIdentity($data['username']);
         $authAdapter->setCredential(md5($data['password']));
         //authenticate
         $result = $authAdapter->authenticate();
         if ($result->isValid()) {
             // store the username, first and last names of the user
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $storage->write($authAdapter->getResultRowObject(array('username', 'first_name', 'last_name', 'role')));
             return $this->_forward('index');
         } else {
             $this->view->loginMessage = "Sorry, your username or\n                password was incorrect";
         }
     }
     $this->view->form = $userForm;
 }
 public function step2Action()
 {
     $namespace = new Zend_Session_Namespace('signup');
     if (!is_null($namespace->sitename) && !is_null($namespace->siteurl)) {
         $userform = new Form_User();
         $userform->addRepeatPassword();
         $userform->setAction('/registration/step2');
         $userform->addDBNoRecordExistsValidator();
         if ($this->_request->isPost()) {
             if ($userform->isValid($this->_request->getPost())) {
                 $namespace->email = $userform->getValue('email');
                 $namespace->password = $userform->getValue('password');
                 $this->_redirect('/registration/step3');
             }
         }
         $this->view->userform = $userform->replaceSubmitLabel("Step 3 >");
         $this->view->sitename = $namespace->sitename;
         $this->view->siteurl = $namespace->siteurl;
     } else {
         $this->_redirect('/auth');
     }
 }