(my environment is: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8 Yii Framework/1.0.3)
Second Scenario - I will try to do the Auth to be closely driven by a database.
-----------------------------------------------------------------------------
Step 1: main.php config file has
Quote
'user'=>array(
'allowAutoLogin'=>FALSE, // disable cookie-based authentication
'class'=>'application.components.WebUser',
),
…
Step 2: LoginForm.php will undervalue the duration of cookie retained User data.
Quote
{
if(!$this->hasErrors()) // we only want to authenticate when no input errors
{
$identity=new UserIdentity($this->txtUsername,$this->txtPassword);
$identity->authenticate();
switch($identity->errorCode)
{
case UserIdentity::ERROR_NONE:
$duration=0; // <span style='color: limeGreen'><<<<=====</span>
Yii::app()->user->login($identity,$duration);
…
Step 3: Injecting my User activerecord properties into the WebUser instance at login time
Quote
class WebUser extends CWebUser
{
public function login($identity,$duration=0)
{
parent::login($identity,$duration);
if( ! empty($identity->id) )
{
$user = <span style='color: purple'>Usuario</span>::model()->findByAttributes( array('de_nick'=>"{$identity->username}", 'de_senha'=>"{$identity->password}") );
if( ! is_null($user) )
{
// --------------------------------
<span style='color: purple'>$propertiesUsuario</span> = array( 'id_usuario', 'de_senha', tp_status', 'de_codigo_ativacao', 'de_observacao', 'de_nick', 'dt_registro', 'dt_cancelamento', 'tp_pessoa', 'id_pessoa_fisica', 'de_config', 'id_perfil', 'arr_role', 'de_theme' );
foreach( $propertiesUsuario as $k )
{
if( isset( $user->$k ) ) {
Yii::App()->user->setState( $k, $user[$k] );
}
}
Yii::App()->user->setState( 'guestName', $user['de_nick'] );
Yii::App()->user->saveIdentityStates();
// --------------------------------
}
}
}
}
?>
Step 4: The second great disappointment: Where are the customized properties?
At the end of actionIndex() method of SiteController I put: var_dump(Yii::App()->user);
Quote
object(WebUser)#8 { ["allowAutoLogin"]=> bool(false) ["guestName"]=> string(5) "Guest" ["loginUrl"]=> array(1) { [0]=> string(10) "site/login" } ["_keyPrefix:private"]=> string(32) "2cd4aca7d9b132f165c210e8cd55c2eb" ["behaviors"]=> array(0) { } ["_initialized:private"]=> bool(true) ["_e:private"]=> NULL ["_m:private"]=> NULL }
Is my property inject mechanism (1) correct ?
(1)----------------------
Yii::App()->user->setState( 'key', 'value' );
Yii::App()->user->saveIdentityStates();
MN