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.

Calling the login function

edited January 2006 in Vanilla 1.0 Help
Hello, I'm trying to rig my site so when users sign into the main part of the site, they are automatically signed into my vanilla forum as well. Is there a login function in vanilla I can call... something like login($username, $password) ? What file is it in, and what files do I need to include for it to work? Happy new year! Andrew


  • Unfortunately i'm not an expert on the subject, but you need to be looking at lussumo people which is involved in vanilla 0.9.3 - it's marks new seperated people management/authentication system to make stuff like what you're doing a lot easier. Take a browse through the files and see how much of it you can follow - if you have any questions i'm sure there will be people on here willing/able to answer (if you search there have already been a couple of discussions about it which may answer your questions)
  • Take a peek at the ValidateUserCredentials() function in the UserManager class.
  • Thanks SirNot, that was exactly what I needed. But I'm new to OO php, and this code has me a little confused. If I'm trying to call that function from a page outside of vanilla, how do I call it, like this? $User->ValidateUserCredentials() ?? and do I need to declare $User first somehow? And what all pages do I need to include besides library/Vanilla.User.class.php ? Sorry, I need my hand held....
  • For a start i'd strongly suggest you grab a copy of 0.9.3 from the svn (or even just the People folder) as i'm fairly sure the reference SirNot made was to People\People.Class.UserManager.php. The user management functions in 0.9.2 are reasonably different and will be depracated as soon as 0.9.3 hits public release. Once you've checked that out, i've a feeling you'd call it by using $UserManager->ValidateUserCredentials(username,password,cookie) (where cookie is either 0 or 1, i think) But i'm sure SirNot will confirm/deny that, as i myself am new to OOP. As for which files to include, he'll probably confirm that too. I *think* you'll atleast need People.Class.UserManager.php and People.Class.Authenticator.php In any case, if you grab the copy of People off the svn stuff might become a little clearer, as that is designed to be stripped apart/used outside of vanilla, wheras the user management stuff in 0.9.2. is fairly integral.
  • NickENickE New
    edited January 2006
    Something as simple as this would work:
    <?php include('appg/settings.php'); include('appg/init_ajax.php'); $UserMng = $Context->ObjectFactory->NewContextObject($Context, 'UserManager'); $UserMng->ValidateUserCredentials($Username, $Password, $Persistant); ?>
    Where presistant is whether it should set a cookie or just as a session (the latter would end when the browser is closed).
  • /me takes note
  • Thanks! Does that apply to .92 or .93?
  • 0.9.2
  • What's different for 0.9.3?
  • NickENickE New
    edited January 2006
    Well, technically you don't have to change anything, but it would result in a lot of redundant code executed. In addition, this way allows you to be more specific in your error reporting:
    $Errors = array(
    	-2 => 'Fatal database error', 
    	-1 => 'Insufficient permissions', 
    	0 => 'Username/password combination not found', 
    $Ret = $Context->Authenticator->Authenticate($Username, $Password, $Persistant);
    if($Ret <= 0) echo($Errors[$Ret]);
  • edited January 2006
    Hi SirNot, I tried that code you suggested above, and got this error: Fatal error: Cannot redeclare class session in /home/policy/public_html/forum/library/Vanilla.Session.class.php on line 14 any ideas? Thanks! (this stuff:) include('forum/appg/settings.php'); include('forum/appg/init_ajax.php'); $UserMng = $Context->ObjectFactory->NewContextObject($Context, 'UserManager'); $UserMng->ValidateUserCredentials($_POST['user'], $_POST['pass'], isset($_POST['remember']));
  • MarkMark Vanilla Staff
    Well that's a wierd bug, now isn't it?

    Lemme see something


  • MarkMark Vanilla Staff
    Hmm. Nevermind, I guess.
  • NickENickE New
    edited January 2006
    Weird. It's pretty much exactly what the SignIn class does, albeit a more stripped down version, so I don't really see how that error could come about. Somehow library/Vanilla.Session.Class.php is being included twice, but where is beyond me. Try it with init_external.php instead of init_ajax.php, and see what happens.
  • Same error, I'm afraid. Any other ideas?
  • Perhaps this is where include_once() would come up trumps throughout the codebase? Or am i misunderstanding the purpose of the function?
  • I tried include_once, require, and require_once, and none produced a different result. Good idea, though.
This discussion has been closed.