Found this Which helps a bit
My query now:
Querying SQL: SELECT * FROM `my_users` `t` WHERE `t`.`email`=:yp0 LIMIT
1. Bound with :yp0='me_email@yahoo.com'
So i take it that my password is causing the problem?
I have been working to adjust the login, so far I have
login.php
<?php
$this->pageTitle=Yii::app()->name . ' - Login';
$this->breadcrumbs=array(
'Login',
);
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
//'enableClientValidation'=>true,
//'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Login'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
LoginForm.php
<?php
/**
* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $email;
public $password;
private $_identity;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
// email and password are required
array('email, password', 'required'),
array('email', 'email'),
array('password', 'authenticate'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'rememberMe'=>'Remember me next time',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
if(!$this->hasErrors())
{
$this->_identity=new UserIdentity($this->email,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect email or password');
}
}
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
/*
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
return true;
*/
}
else
return false;
}
}
UserIdentity.php
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
// Need to store the user's ID:
private $_id;
public function authenticate()
{
/*$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);*/
//http://www.larryullman.com/2010/01/07/custom-authentication-using-the-yii-framework/
$users = MyUsers::model()->findByAttributes(array('email'=>$this->username));
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID; // no user found
else if($users[$this->username]!== sha1($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID; // password failed
else
$this->_id = $users->id;
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
// Store the role in a session:
$this->setState('type', $users->type);
}
public function getId() // override getId to store user ID
{
return $this->_id;
}
}
This has beaten me so far, so would be nice if anyone can look at it with fresh eyes 