Yii Framework Forum: Something Wrong With Saving Changes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Something Wrong With Saving Changes

#1 User is offline   tonny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 25-December 12

Posted 10 March 2013 - 03:28 AM

Hi, guys. I want to let user change his password. I'm at my wits end with this simple piece of code:
    public function actionChangepass()
	{

              $model=Register::model()->findByPk(Yii::app()->user->id);
   		// collect user input data
              if(isset($_POST['Register']))
		{

                   if($_POST['Register']['newpassword']!=$_POST['Register']['appnewpassword'])
                   {
                      Yii::app()->user->setFlash('changepass','Confirm password once more.');
                      $model->password='';
                      $this->render('chpass',array('model'=>$model));exit;
                   }
                   if(($model->password)!=$model->hashPassword($_POST['Register']['password'],$model->salt))
                   {
                     Yii::app()->user->setFlash('changepass','Password is invalid.');
                     $model->password='';
                     $this->render('chpass',array('model'=>$model));exit;
                   }
                   else
                   {
                     $model->password=$model->hashPassword($_POST['Register']['newpassword'],$model->salt);
                     $model->update();
                     $this->redirect(Yii::app()->user->returnUrl);
                   }
		}
                else
                {
                 $model->password='';
                 $this->render('chpass',array('model'=>$model));
                } 
}

Please, help me!
It saves abracadabra hash in password field, instead of hashed new password.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users