Hi All
I change login functions related to database
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
{
// Need to store the user's ID:
private $_id;
public $password;
public $status;
/**
* 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.
*/
public function authenticate()
{
$user = Users::model()->findByAttributes(array('email'=>$this->username));
if ($user===null) { // No user found!
$this->errorCode=self::ERROR_USERNAME_INVALID;
} else if ($user->password !== SHA1($this->password) ) { // Invalid password!
$this->errorCode=self::ERROR_PASSWORD_INVALID;
} else { // Okay!
$this->errorCode=self::ERROR_NONE;
// Store the role in a session:
$this->setState('status', $user->status);
$this->setState('id', $user->user_id);
$this->_id = $user->user_id;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
login Action in siteController.php
public function actionLogin()
{
$model=new LoginForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
$username=$_POST['LoginForm']['email'];
$password=$_POST['LoginForm']['password'];
if($model->validate() )
$identity=new UserIdentity($username,$password);
if($identity->authenticate()){
$this->redirect(Yii::app()->user->returnUrl);
}
else
{
$this->redirect(Yii::app()->user->returnUrl);
}
}
// display the login form
$this->render('login',array('model'=>$model));
}
the problem
my sites folder like that :
Site
Admin
user
when I login and call Yii::app()->user->isGuest return true in site folder
and false in another folders
How I can fix it to return false on all folders !!!
Thanks in advance