Tarragon
سه شنبه 21 بهمن 1393, 11:25 صبح
سلام
من دارم یک پروژه رو با Yii 1.1 می نویسم.
مشکلی که دارم اینه که من بعنوان کاربر وارد سایت می شم. با موفقیت وارد می شم. در صفحه اول گزینه بالا هست "logout (test)" ولی وقتی می رم تو قسمت ads که با migration جدولشو طراحی کردم و با gii براش crud ساختم من رو وارد شده به حساب نمیاره بالا هم هست "login".
این کدهام :
قسمت userIdentity :
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$user=User::model()->find('LOWER(username)=?',array(strtolower($this->username)));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->setState('lastLogin', date("m/d/y g:i A", strtotime($user->last_login_time)));
$this->setState('isAdmin', strtolower($user->username) == 'admin');
$user->saveAttributes(array(
'last_login_time'=>date("Y-m-d H:i:s", time()),
));
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
قسمت migration جدول ads :
$this->createTable(
'{{ads}}',
array(
'id' => 'pk',
'name' => 'string NOT NULL',
'description' => 'text NOT NULL',
'price' => 'int(10) DEFAULT NULL',
'price_type' => 'TINYINT(1) DEFAULT \'0\'',
'img' => 'string DEFAULT NULL',
'category_id' => 'int(10) DEFAULT NULL',
'create_time' => 'datetime DEFAULT NULL',
'create_user_id' => 'int(11) DEFAULT NULL',
'update_time' => 'datetime DEFAULT NULL',
'update_user_id' => 'int(11) DEFAULT NULL',
),
'ENGINE=InnoDB'
);
اگر اطلاعات کافی نیست بفرمایید تا قسمت مورد نیاز رو بزارم. اگر هم لازم به team viewer هست بفرمایید تا اطلاعات رو پ خ کنم.
سپاس فراوان.
من دارم یک پروژه رو با Yii 1.1 می نویسم.
مشکلی که دارم اینه که من بعنوان کاربر وارد سایت می شم. با موفقیت وارد می شم. در صفحه اول گزینه بالا هست "logout (test)" ولی وقتی می رم تو قسمت ads که با migration جدولشو طراحی کردم و با gii براش crud ساختم من رو وارد شده به حساب نمیاره بالا هم هست "login".
این کدهام :
قسمت userIdentity :
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$user=User::model()->find('LOWER(username)=?',array(strtolower($this->username)));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->setState('lastLogin', date("m/d/y g:i A", strtotime($user->last_login_time)));
$this->setState('isAdmin', strtolower($user->username) == 'admin');
$user->saveAttributes(array(
'last_login_time'=>date("Y-m-d H:i:s", time()),
));
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
قسمت migration جدول ads :
$this->createTable(
'{{ads}}',
array(
'id' => 'pk',
'name' => 'string NOT NULL',
'description' => 'text NOT NULL',
'price' => 'int(10) DEFAULT NULL',
'price_type' => 'TINYINT(1) DEFAULT \'0\'',
'img' => 'string DEFAULT NULL',
'category_id' => 'int(10) DEFAULT NULL',
'create_time' => 'datetime DEFAULT NULL',
'create_user_id' => 'int(11) DEFAULT NULL',
'update_time' => 'datetime DEFAULT NULL',
'update_user_id' => 'int(11) DEFAULT NULL',
),
'ENGINE=InnoDB'
);
اگر اطلاعات کافی نیست بفرمایید تا قسمت مورد نیاز رو بزارم. اگر هم لازم به team viewer هست بفرمایید تا اطلاعات رو پ خ کنم.
سپاس فراوان.