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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.