Beispiel #1
0
 /**
  * authenticate method using Doctrine_Core
  * @param string $username
  * @param string $password
  * @throws Exception
  * @return Model_User 
  */
 public static function authenticate($username, $password)
 {
     $user = Doctrine_Core::getTable('Model_User')->findOneByUsername($username);
     if ($user) {
         $salt = new My_Auth_Salt();
         $salt->setDynamicSaltString($user->saltstring);
         $salt->setPassword($password);
         $seasonedpassword = $salt->getEncryptedPassword();
         if ($user->password == $seasonedpassword) {
             return $user;
         }
         throw new Exception(self::WRONG_PW);
     }
     throw new Exception(self::NOT_FOUND);
 }
Beispiel #2
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();
     }
 }
Beispiel #3
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!';
         }
     }
 }