public function authenticate(MOXMAN_Auth_User $user)
{
$config = MOXMAN::getConfig();
$session = new CI_Session();
// Check logged in key
$sessionValue = $session->userdata($config->get("CodeIgniterAuthenticator.logged_in_key", "loggedin"));
if (!$sessionValue || $sessionValue === "false") {
return false;
}
// Extend config with session prefixed sessions
$sessionConfig = array();
$configPrefix = $config->get("CodeIgniterAuthenticator.config_prefix", "moxiemanager");
if ($configPrefix) {
$allData = $session->all_userdata();
foreach ($allData as $key => $value) {
if (strpos($key, $configPrefix) === 0) {
$sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value;
}
}
}
// Extend the config with the session config
$config->extend($sessionConfig);
// Replace ${user} with all config items
$key = $config->get("CodeIgniterAuthenticator.user_key");
if ($key) {
$value = $session->userdata($key);
$config->replaceVariable("user", $value);
$user->setName($value);
}
return true;
}