Single Login with a CMS [message #23322] |
Sat, 12 March 2005 10:38 |
LastQuark
Messages: 12 Registered: August 2003
Karma: 0
|
Junior Member |
|
|
How can I implement single login with a CMS? I will login to the CMS and it will simultaneously log me in to FUDforum?
Any easy solution?
|
|
|
Re: Single Login with a CMS [message #23325 is a reply to message #23322] |
Sat, 12 March 2005 16:01 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Yeah... you basically need to have forum's user_login() function executed by the CMS logging in the user into the forum.
FUDforum Core Developer
|
|
|
|
Re: Single Login with a CMS [message #23339 is a reply to message #23336] |
Sun, 13 March 2005 05:34 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
The function I had mentioned can be found inside the users_reg.inc.t script found inside the src/ directory. This script in compiled form would be inside include/theme/default/users_reg.inc.
The code inside the function is pretty simple so, it may be a good idea to simply move the code into your own application.
FUDforum Core Developer
|
|
|
|
Re: Single Login with a CMS [message #23360 is a reply to message #23354] |
Sun, 13 March 2005 20:58 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
I've added a script to the CVS (forum_login.php) that can be found inside the forum's scripts/directory.
This script implements external_fud_login() function that takes the forum user id as a single parameter and will try to log that user in, creating a cookie and returning you the session id for that user.
To use the script you simply need set configuration directive within the script that identifies the location of the GLOBALS.php file.
The script it attached to this message.
FUDforum Core Developer
|
|
|
|
|
|
|
Re: Single Login with a CMS [message #23392 is a reply to message #23322] |
Tue, 15 March 2005 08:10 |
LastQuark
Messages: 12 Registered: August 2003
Karma: 0
|
Junior Member |
|
|
...one day later...
How am I going to execute this file? Should I use 'onsubmit' to the form name to execute it like:
/* filename = fudlogin.xd */
<form action="&xar-modurl-roles-user-login;" method="post" enctype="application/x-www-form-urlencoded" onsubmit="forum_login.php">
<div>
<div style="text-align: left; margin: 3px;"><label for="uname#$blockid#"><xar:mlstring>Username</xar:mlstring>:</label></div>
<div style="text-align: right; margin: 3px;"><input type="text" name="uname" id="uname#$blockid#" maxlength="64" size="10" /></div>
</div>
<div>
<div style="text-align: left; margin: 3px;"><label for="pass#$blockid#"><xar:mlstring>Password</xar:mlstring>:</label></div>
<div style="text-align: right; margin: 3px;"><input type="password" name="pass" id="pass#$blockid#" maxlength="64" size="10" /></div>
</div>
<xar:if condition="xarConfigGetVar('Site.Session.SecurityLevel') ne 'High'">
<div style="text-align: center; margin: 3px;"><input type="checkbox" name="rememberme" id="rememberme#$blockid#" value="1" />
<label for="rememberme#$blockid#"><xar:mlstring>Remember me</xar:mlstring></label></div>
</xar:if>
<input type="hidden" name="redirecturl" id="returnurl#$blockid#" value="#$return_url#" />
<div style="text-align: center; margin: 3px;"><input type="submit" value="#$signinlabel#" /></div>
<xar:if condition="$showregister eq 1">
<div style="text-align: center; margin: 3px;"><xar:mlstring>Need an account?</xar:mlstring><br />
<a href="#$registerurl#"><xar:mlstring>Register here</xar:mlstring></a>.</div>
</xar:if>
</form>
...or should I execute it in the function as follows as soon as the user is authenticated (see arrows):
<?php
/* filename = authenticate_user.php */
function authfud__get_fud_userdata($connect,$username,$pass)
{
$prefix = xarModGetVar('authfud','prefix');
$password = md5($pass);
$table = $prefix.'users';
if($connect) //just double-checking the connection.
{
// connect to the FUDforum database and get the user data
//$inv_db = mysql_select_db($database, $connect);
$query = "SELECT * FROM " . $table . " WHERE login=? AND passwd=?";
$connect->SetFetchMode(ADODB_FETCH_ASSOC);
$bindvars = array($username, $password);
$result =& $connect->Execute($query,$bindvars);
if (!$result) {
//error
$msg = "FUDforum: Query to $table has failed: " . $connect->ErrorMsg();
xarErrorSet(XAR_SYSTEM_EXCEPTION, 'SQL_ERROR',
new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
error_log("FUDforum Error: Query to $table failed");
return false;
}
if ($result->EOF)
{
//incorrect login
$msg = xarML('Wrong username (#(1)) or pass (not shown).', $username);
xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
$result->Close();
return false;
}
else {
//correct login. return uid.
if ($result->fields['users_opt']=='0')
{
//user inactive
$msg = xarML('User #(1) not activated.', $username);
xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
$result->Close();
return false;
}
else
{
$user_data=$result->fields;
$result->Close();
return $user_data;
}
}
INCLUDE('forum_login.php'); <<<<<<<========
}
}
?>
Attached is the zip file that contains the files of the FUDforum module that was created specifically to work with Xaraya.
Pardon my ignorance. Several PHP books for Dummies are on the way...I can't wait to get this mod working before the books arrive.
-
Attachment: authfud.zip
(Size: 24.16KB, Downloaded 740 times)
|
|
|
Re: Single Login with a CMS [message #23398 is a reply to message #23392] |
Tue, 15 March 2005 15:28 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Well, one you've successfully retrieved the user you now have that user's forum id stored inside $result->fields['id'].
So, before the return $user_data;, which indicates a sucessful login, you need to include the script I've provided and call the external_fud_login() function with $result->fields['id'] parameter.
FUDforum Core Developer
|
|
|
|
|
|
|
|