i want to authenticate the UserIdentity against a database, not a table. How can I achieve this?
I've just changed the authenticate() - Method:
try {
$conection = new CDbConnection("mysql:host=web", $this->username, $this->password);
$conection->active = true;
$this->errorCode = self::ERROR_NONE;
// Store password in UserIdentity
$this->setState("password", $this->password);
// Store password in session
//Yii::app()->session->add("password", $this->password);
} catch (Exception $ex) {
$this->errorCode = self::ERROR_AUTHENTICATION_FAILED;
$this->errorMessage = $ex->getMessage();
}
So far, that works pretty fine. My problem now is, that the user's login data is needed to authenticate against the database all the time. So I changed the application config as follows:
But, of course, if the user calls the login form, this information is (not yet) available (username, password) and the application throws an exception.
So here's the question:
How can I configure the app to only connect to the database, if the user is logged in?
Do not set username and password in app config. Set them in authenticate() after the user is authenticated (or simply reuse the connection in authenticate()).