Vares
(Edu Nievares)
August 17, 2011, 8:46am
1
Hello all!
I have a big problem, I have one application to manage users and other two that use that users.
How can I log in my secondary applications with the users that I had create on the first, normally I do this:
public function authenticate() {
$user = Usuario::model()->findByAttributes(array('usuario' => $this->username));
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
In the file protected/comonents/useridetity.php
But now, my model class is in other application
Thanks and sorry about my english
mdomba
(Maurizio Domba Cerin)
August 17, 2011, 10:03am
2
If the database is always the same… you can just copy your model to the other applications…
better solution would be to have a common folder for all 3 applications… and put there this model so that you don’t need to copy it every time you make changes…
Vares
(Edu Nievares)
August 17, 2011, 10:58am
3
mdomba:
If the database is always the same… you can just copy your model to the other applications…
better solution would be to have a common folder for all 3 applications… and put there this model so that you don’t need to copy it every time you make changes…
Thanks!!
I created a model class again in the main application, and I create my own active record but I still caný authenticate, I wirte my code next.
My authenticate method:
private $_id;
public function authenticate()
{
$user=Administrador::model()->findByAttributes(array('administrador' => $this->login));
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
}
else
{
if ($user->password !== $this->password)
{
$this->errorCode = self::ERROR_PASSWORD_INVALID;
}
else
{
$this->_id = $user->id;
$this->errorCode = self::ERROR_NONE;
}
}
return!$this->errorCode;
//Faltan los roles
}
My own active record
class MyActiveRecord extends CActiveRecord {
private static $dbmarco = null;
protected static function getMarcoDbConnection()
{
if (self::$dbmarco !== null)
return self::$dbmarco;
else
{
self::$dbmarco = Yii::app()->dbmarco;
if (self::$dbmarco instanceof CDbConnection)
{
self::$dbmarco->setActive(true);
return self::$dbmarco;
}
else
throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
}
}
I inherite this active record in my model Administrator class and then I added the next function
public function getDbConnection()
{
return self::getMarcoDbConnection();
}
In the main.php I have this
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'dbmarco',
),
I dont know why I can´t authenticate users
mdomba
(Maurizio Domba Cerin)
August 17, 2011, 11:44am
4
Your code is not readable… please use the code button when posting code (<> on the editor toolbar)
If you are getting an error… than write here what error do you get… but if not… you need to debug a bit your code to see what is happening and why and what does not work…
Vares
(Edu Nievares)
August 18, 2011, 9:58am
5
mdomba:
Your code is not readable… please use the code button when posting code (<> on the editor toolbar)
If you are getting an error… than write here what error do you get… but if not… you need to debug a bit your code to see what is happening and why and what does not work…
There is no error, only the white page.
Vares
(Edu Nievares)
August 18, 2011, 2:58pm
6
Finally I found the problem but it is not resolved.
When I fetch the order of my databases in the main.php file I can authenticate my user but I can see the other db
I did everything http://www.yiiframework.com/wiki/123/multiple-database-support-in-yii/#hh1
I had my own active record, I inherited it in the correct model, but when I try to access to its content I only wiew a white page, If I don inherite the new active record I see the next error message
“The table “FAQ” for active record class “FAQ” cannot be found in the database.” <–Thatś correct it’s in another data base.
Iḿ becoming crazy