Hi,
If I encrypt the password with md5 works well. However, if I use CPasswordHelper this error appears in the form:
Please fix the following input errors: Password must be repeated exactly.
This code doesn’t work:
public function actionCreate()
{
$model=new User('insert');
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->validate())
{
$model->password = CPasswordHelper::hashPassword($model->password);
$model->repeatPassword = CPasswordHelper::hashPassword($model->repeatPassword);
if($model->save())
{
$this->redirect(array('admin', 'lang' => $_POST['lang']));
}
}
}
$model->password = null;
$model->repeatPassword = null;
$this->render('create',array(
'model'=>$model,
));
}
This code works:
public function actionCreate()
{
$model=new User('insert');
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->validate())
{
$model->password = md5($model->password);
$model->repeatPassword = md5($model->repeatPassword);
if($model->save())
{
$this->redirect(array('admin', 'lang' => $_POST['lang']));
}
}
}
$model->password = null;
$model->repeatPassword = null;
$this->render('create',array(
'model'=>$model,
));
}