Hi,
I am admin for the site kulsara.com which is based on Simple Machines Forum (SMF) (see www.simplemachines.org). I would like to use the login information from SMF for SSO with question2answer (QA). But it does not seem to work -- any help or pointers much appreciated.
SMF has its own MySQL database and I am using the same database for QA as well. So in qa-config.php, I have used the parameters corresponding to this database. This part is okay, because after installation, I can see that the 11 QA tables are created in the database. I have also set QA_EXTERNAL_USERS to true.
In qa-external-users.php file, I have edited the qa_get_login_links function, and that seems to be okay. For instance, you can go to www.kulsara.com/qa and upon clicking the login or register links, you are redirected to the login/register pages of the kulsara site.
I think the problem is in the qa_get_logged_in_user function. Here is what my function looks like:
function qa_get_logged_in_user($qa_db_connection)
{
session_start();
global $context;
if ($context['user']['is_logged']) {
$userid=$context['user']['name'];
$result=mysql_fetch_assoc(
mysql_query(
"SELECT emailAddress FROM smf_members WHERE memberName='".mysql_real_escape_string($userid, $qa_db_connection)."'",
$qa_db_connection
)
);
if (is_array($result))
return array(
'userid' => $userid,
'publicusername' => $userid,
'email' => $result['emailAddress'],
'level' => ($userid=='admin') ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
);
}
return null;
}
The qa_get_user_email is as follows:
function qa_get_user_email($qa_db_connection, $userid)
{
$result=mysql_fetch_assoc(
mysql_query(
"SELECT emailAddress FROM smf_members WHERE memberName='".mysql_real_escape_string($userid, $qa_db_connection)."'",
$qa_db_connection
)
);
if (is_array($result))
return $result['emailAddress'];
return null;
}
The final function that was changed is qa_get_userids_from_public:
function qa_get_userids_from_public($qa_db_connection, $publicusernames)
{
$publictouserid=array();
foreach ($publicusernames as $publicusername)
$publictouserid[$publicusername]=$publicusername;
return $publictouserid;
}
Any suggestions on why SSO is not working much appreciated. Thanks.