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.

Integration of Login procedure

edited October 2007 in Vanilla 1.0 Help
Anyone got some hints on integrating the login/session procedure of vanilla into another site? I would like to integrate a login box into my site which would start the session on the vanilla user database. I'd like to carry this session over different pages and when opening the forum itself the user shouldn't have to login again.

Comments

  • To clear things up: - use of the vanilla user database & mangement without chaning anything - create an own login box that logs users in (using the usual vanilla login procedure) - handle session over all pages of my site (including non vanilla sites) - running session should also work on vanilla sites I've got some php knowledge. But I'd like to hear some hints on how to accomplish this task without screwing everything up :) Thanks
  • There is a basic integration guide written for WordPress, reading that should help you get a feel of it:
    http://lussumo.com/docs/doku.php?id=vanilla:integration:wordpress

    All the people classes in the framework folder handle the authentication and registration inside Vanilla. Not having done this myself (yet), you probably just have to include them in the same manner that Vanilla does.
  • This integration is quite complicated. I was thinking about something very easy since I'm willing to work with the user management and database of vanilla. All I'm trying to accomplish is the creation of a little login box on my non vanilla sites that by clicking "login" should log the user in with the usual Vanilla log in procedure (creating cookies and session). The session should then stay alive over all non vanilla sites and on the forum itself of course. How can I manage this? Thanks
  • I'm looking for this, too. Ideally, I'd love to see an include or simple function I could plop into my existing login script that would also log in to Vanilla. Ideally, something that was 'decoupled' from the framework that could easily be implemented without a lot of dependencies. I'd just like to be able to pass the submitted username and password on to a function or class, and not have to do a lot of customization. I realize that this may go against the architecture and philosophy of the way Vanilla is built, so please don't flame me. :)
  • Right... that article is about using an existing authentication system in place of People. These topics are probably more in line with what you need: http://lussumo.com/community/discussion/2486/ http://lussumo.com/community/discussion/1300/understanding-people/#Item_3
  • Hmmm... that's not exactly what I'm looking for. Those scripts allow you to check to see if you are logged in, but don't actually perform the task of logging you in. Thanks for the links, though! I've got an existing login script that logs the user in to my main site, then redirects them to the home page as a logged-in user. I've already integrated the sign-up so that the users have the same username and password on the main site as on the vanilla forum. So, it seems to me that my script could just: 1. log in to the main site 2. pass the credentials on and perform the vanilla login. I've just not been able to decipher the authentication process in Vanilla because it is so integrated with the framework.
  • The Authenticate function on People.Class.Authenticator.php should do exactly what you need. Feed it a username and password and it will make a session for the user.
  • Alright I haven't really tried the code below for the login function but I suppose this could work, you might try and post back to us? include('appg/settings.php'); include_once("./forum/appg/init_people.php"); // get those parameters from the login $Username = ; $Password = ; $Remember= ; // $Ret should be the $UserID if the login has been successful $Ret = $Context->Authenticator->Authenticate($Username, $Password, $Remember); if ($Ret > 0) { // user has been authenticated, send him to the homepage } How do the pages of the homepage have to look now? I don't have to use a session_start(), right? Does this code suffice? include_once("./forum/appg/settings.php"); include_once("./forum/appg/init_people.php"); if ($Context->Session->UserID > 0) { //Person is logged in } else { //Person is not logged in }
  • On my own integration, what I have done is just use vanilla login box, only themed to fit in the site design.
    Then i wrote a delegate function attached to login process to perform needed action, in my case this is checking against another database, in your it might just be putting some variable in the session array.
    Basically, write a simple extension to attach to the proper delegate: if ($Context->SelfUrl == 'people.php') { $Context->AddToDelegate("SignInForm", "PreValidPostBackRender", "your_custom_function"); }
  • i recieve an error when using this code: arse error: syntax error, unexpected ';' in /home/.guy/justinmyers/yourwebsite.org/index3.php on line 14 include('appg/settings.php'); include_once("./forum/appg/init_people.php"); // get those parameters from the login $Username = ; $Password = ; $Remember= ; // $Ret should be the $UserID if the login has been successful $Ret = $Context->Authenticator->Authenticate($Username, $Password, $Remember); if ($Ret > 0) { // user has been authenticated, send him to the homepage }
  • anybody?
  • I'm assuming line 14 of index3.php starts with $Username =;?

    If so, you just forgot to delcare what the $Username, $Password and $Remember vars are:

    include('appg/settings.php'); include_once("./forum/appg/init_people.php"); // get those parameters from the login $Username = ''; $Password = ''; $Remember= ''; // $Ret should be the $UserID if the login has been successful $Ret = $Context->Authenticator->Authenticate($Username, $Password, $Remember); if ($Ret > 0) { // user has been authenticated, send him to the homepage }
  • Hey Developers, I want to do the same integration with Vanilla and www.thinkbigg.com. Anyone that can do it, email me at dave@novakandcompany.com and I will pay you to get it done. I just want both the forum and the main site to have the same registration and a little bit of the design should mesh! Thank you, Dave Novak
  • I wanted to post my experience back. The code in comment #9 http://lussumo.com/community/?CommentID=54642 works great. You can even pass an MD5'ed password. You have to set the values for $Username, $Password and $Remember. Thanks for an easy integration method.
  • edited June 2007
    Yes! I been looking for something like that and it works grate! I think that piece of code should be added to the Vanilla wiki By the way it took me hours to realize that the part of the code that checks if the user is already logged in didn't work because of the cookie path. If you are trying to use that function from your root path then remember to change the cookie path on the settings file.
  • I have the following code saved as a loginlink.php file in another location on the same site as my forum. It provides the same "sign in" and "logged in as Username (sign out)" infos as my forum.

    <?php // ADAPT PATHS TO YOUR SETUP include("../forum/appg/settings.php"); include_once("../forum/appg/init_people.php"); if ($Context->Session->UserID) { //user is logged in - show name and logout link; echo '<li>'.str_replace('//1', $Context->Session->User->Name, $Context->GetDefinition('SignedInAsX')).' (<a href="'.$Context->Configuration['SIGNOUT_URL'].'">'.$Context->GetDefinition('SignOut').'</a>)</li>'; } else { // user is not logged in - show login link; echo '<li><a href="'.$Context->Configuration['SIGNIN_URL'].'">'.$Context->GetDefinition('SignIn').'</a></li>'; } ?>

    When called up in the browser it works fine, replicating the behaviour on the forum exactly.
    However, as soon as I include it from my smarty template with
    {php}include("loginlink.php");{/php}
    it refuses to work at all. I've checked the smarty settings and php is allowed and security is set to false. I temporarily added echo statements to the included files to see if they were indeed being referenced and they are — the echoes appear but nothing else.

    I'm not a smarty afficionado, so can anyone advise on any possible conflicts or ways around it?
  • Maybe the includes in that file are not being loaded.
  • I added echos temporarily to loginlink.php to appg/settings.php, appg/init_people.php and also conf/language.php, which is called from the other init files, and they all echo successfully through to the smarty-based page, so they are being referenced. Also it works perfectly when not called from smarty.
  • jakob_r, i got the same result when trying to include your script in a wordpress theme. loading the file itself worked fine, but included in the theme - nope. -cannot modify header information- and then something about appg/headers.php
  • *bump*

    no ideas anyone? I'd really like to get this working.
This discussion has been closed.