Пример #1
0
 public function createAccountAction()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/forms/user.ini', 'user');
     $this->view->form = new Zend_Form($config->user);
     if ($this->getRequest()->isPost()) {
         $salt = new My_Auth_Salt($this->_getParam('password'), 40);
         $u = new Model_User();
         $u->username = $this->_getParam('username');
         $u->password = $salt->getEncryptedPassword();
         $u->saltstring = $salt->getDynamicSaltString();
         $u->name = $this->_getParam('name');
         $u->address = $this->_getParam('address');
         $u->phone = $this->_getParam('phone');
         $u->email = $this->_getParam('email');
         $u->save();
     }
 }
Пример #2
0
 public function changePasswordAction()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/forms/user.ini', 'change-password');
     $this->view->form = new Zend_Form($config->user);
     if ($this->getRequest()->isPost()) {
         $user = Zend_Auth::getInstance()->getIdentity();
         $salt = new My_Auth_Salt();
         $salt->setDynamicSaltString($user->saltstring);
         $salt->setPassword($this->_getParam('oldpassword'));
         $seasonedpassword = $salt->getEncryptedPassword();
         if ($user->password == $seasonedpassword) {
             $salt = new My_Auth_Salt($this->_getParam('newpassword'), 40);
             $user->saltstring = $salt->getDynamicSaltString();
             $user->password = $salt->getEncryptedPassword();
             $user->save();
             $this->_redirect('/user/');
         } else {
             $this->view->message = 'Old Password does not match!';
         }
     }
 }