Jump to content

Integrating existing auth system with PHPBB3


bcoffin

Recommended Posts

I  have an authentication system in place for my site.

I need to have it automatically log users into a phpbb installation (release 3).

 

Found this code:

    
<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = './';    //Path to forum
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
     
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup('ucp');

    if($user->data['is_registered'])
    {
        echo "Welcome " . $user->data['username']; //User is already logged in
    }
    else if(isset($_POST['login']))
    {
        $username = request_var('username', '', true);
        $password = request_var('password', '', true);
        $autologin = (!empty($_POST['autologin'])) ? true : false;

        $result = $auth->login($username, $password, $autologin);

        if ($result['status'] == LOGIN_SUCCESS)
        {
            //User was successfully logged into phpBB
            $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");

            // append/replace SID
            $redirect = reapply_sid($redirect);
            meta_refresh(1, $redirect);
            
            trigger_error('LOGIN_REDIRECT');
        }
        else
        {
            echo 'Bad Login';    //User's login failed
        }
    }
    else
    {
        echo '<form action="index.php" method="post">
              <label for="username">Username:</label><input type="text" name="username" /><br />
              <label for="password">Password:</label><input type="password" name="password" /><br />
              <input type="hidden" name="redirect" value="index.php" />
              <label for="autologin">Automatic login:</label><input type="checkbox" name="autologin" id="autologin" class="checkbox" />
              <input type="submit" value="login" name="login" />
              </form>';
    }
    ?>

 

At this link: http://www.phpbb.com/community/viewtopic.php?f=71&t=983935

 

 

And when I test it, the PHPBB auth system return SUCCESS, then redirects to a forum page.

That forum page shows the user as not-logged-in.

 

Any help appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.