Not sure what is wrong, but he says my email address / password is incorrect. This only happens when my password is hashed. Just looking for a simple password hashing, I donβt need something complicated.
in my UserIdentity. I tried a couple of ways to do this, none of them work.
$loginSuccess = false;
if ($user->hashed === 'Y') {
$loginSuccess = (md5($this->password) === $user->password);
} else {
$loginSuccess = ($this->password === $user->password);
}
if($loginSuccess==false) {
In my controller:
$model=new LoginForm;
if(Yii::app()->request->isAjaxRequest)
{
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
$password = $_POST['LoginForm']['password'];
$hash = CPasswordHelper::hashPassword($password);
if (CPasswordHelper::verifyPassword($model->password, $hash))
{
if($model->validatePassword($password) && $model->login())
{
when connecting to the site:
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
$hash = CPasswordHelper::hashPassword($_POST['User']['password']);
$model->password = $hash;
if($model->validate())
source
share