Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Authenticating a Vanilla user from outside the Vanilla framework?
Ok, here's my dilema. I'm creating a website with a log in box on the main page (outside Vanilla). My idea is to let visitors log in to Vanilla from this main page, but without actually going to the Vanilla forums. Whether they correctly or incorrectly logged in, I want them to go right back to the main page again after filling out the log in box.
Once a visitor is logged in and on the main page (still outside Vanilla), I would also like to verify that they are indeed logged in. Logged in visitors will see a special menu and information.
How can I accomplish this? I tried using ob_start() in PHP and logging in that way behind the scenes, but it didn't work. There's still nothing in the $_SESSION['LussumoUserID'] variable. Here's the code I tried:
[CODE]
ob_start();
$fname = "http://www.domainname.com/vanilla/people.php?PostBackAction=SignIn&ReturnUrl=&Username=" . $_REQUEST["Username"] . "&Password=" . $_REQUEST["Password"] . "&RememberMe=" . $_REQUEST["RememberMe"];
$fhandle = fopen($fname, "r");
if( !$fhandle ) { Error("The $fname page could not be found."); }
$document = "";
while( $line = fgets($fhandle) )
{
$document .= $line;
}
fclose($fhandle);
echo $document;
$buffer = ob_get_contents();
ob_end_clean();
[/CODE]
Or do I need to manually set session variables from my own PHP script and verify the username and password myself with the MySQL database?
Your help would really be appreciated. I'm on a tight deadline with this.
Thanks,
- Matt.
Once a visitor is logged in and on the main page (still outside Vanilla), I would also like to verify that they are indeed logged in. Logged in visitors will see a special menu and information.
How can I accomplish this? I tried using ob_start() in PHP and logging in that way behind the scenes, but it didn't work. There's still nothing in the $_SESSION['LussumoUserID'] variable. Here's the code I tried:
[CODE]
ob_start();
$fname = "http://www.domainname.com/vanilla/people.php?PostBackAction=SignIn&ReturnUrl=&Username=" . $_REQUEST["Username"] . "&Password=" . $_REQUEST["Password"] . "&RememberMe=" . $_REQUEST["RememberMe"];
$fhandle = fopen($fname, "r");
if( !$fhandle ) { Error("The $fname page could not be found."); }
$document = "";
while( $line = fgets($fhandle) )
{
$document .= $line;
}
fclose($fhandle);
echo $document;
$buffer = ob_get_contents();
ob_end_clean();
[/CODE]
Or do I need to manually set session variables from my own PHP script and verify the username and password myself with the MySQL database?
Your help would really be appreciated. I'm on a tight deadline with this.
Thanks,
- Matt.
0
This discussion has been closed.
Comments
I'll try that right away.
include('path/appg/settings.php');
include('path/appg/init_ajax.php');
(instead of init_ajax.php, you can use init_people.php or init_vanilla.php, but init_ajax.php is the slimer one)
And for login, you send them to people.php?ReturnUrl=http://where.everyouw.ant
When logged-in, you have access to $Context->Session->UserID or $Context->Session->User->Name for exemple
Yes, I did figure that out. I simply added md5() around the password and that was that. Although I couldn't get it to accept both uppercase and lowercase like the Vanilla login can.
Dinoboff:
And you are right, I do need the init_ajax.php include for login to work properly. But I'm having a heck of a time with the sessions. They seem to conflict with my script's session handling...or something. When I uncomment both includes after I'm logging in, it wants to redirect me to people.php which can't be found. Then I need to clear my browser's cookies to clear the problem.
How can I create a log out button via my script? I don't think the logout routine accepts the handy ReturnUrl variable. Or if it does, it isn't working for me. It always shows the Vanilla logout box instead.
Thanks for your help so far. This is so frustrating.
index.php -> ob_start() -> login.php -> ob_start (settings.php)
Thanks so much!
$Context->Session->End($Context->Authenticator);