Vanilla Php SSO login Issue

Good morning everyone… I have a small login and register system and I am integrating vanilla forums using the jsconnect plugin with the php library. I have everything set as required by vanilla forums, when I login it logs me into the site as normal but does not log me into the forums. however the logout works site wide.

in the js connect plugin settings

I have my authenticate url set to

http://mysite.com/auth.php

This is my login function

[php]

function login_user($email, $password){

$active = 1;

$db = dbconnect();
$stmt = $db->prepare('SELECT * FROM users WHERE email = ? AND active= ?');
$stmt->bind_param('si', $email, $active);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows == 1) {
    $row = $result->fetch_array();
    
    $id = $row['id'];
    $email = $row['email'];
    $username = $row['username'];
    $db_password = $row['password'];
    
    isset($_POST['remember']) ? $remember = $_POST['remember'] : $remember = "";
    
    if (password_verify($password, $db_password)) { 
        
        $_SESSION['id'] = $id;
        $_SESSION['email'] = $email;
        $_SESSION['username'] = $username;
        
        $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
        $_SESSION['last_active'] = time();
        $_SESSION['fingerprint'] = $fingerprint;
        
       if($remember === "yes"){
        rememberMe($id);
         }
        
        return true;
    } else {
        return false;
    }
    return true;
} else {
    return false;
}

}

[/php]

this is my authenticate.php

[php]
include_once ‘…/db/db.php’;
include_once ‘…/db/functions.php’;
require_once ‘…/vanilla/plugins/jsconnect/functions.jsconnect.php’;

// 1. Get your client ID and secret here. These must match those in your jsConnect settings.
$clientID = “07777”;
$secret = “0777”;

// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder

if(isset($_SESSION[‘user’]))
$signedIn = true;

// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();

if ($signedIn) {
// CHANGE THESE FOUR LINES.

$user[‘uniqueid’] = $_SESSION[‘user’][‘id’];
$user[‘name’] = $_SESSION[‘user’][‘username’];
$user[‘email’] = $_SESSION[‘user’][‘email’];

}

// 4. Generate the jsConnect string.

// This should be true unless you are testing.
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
$secure = true;

WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

exit();

[/php]

the resources I grabbed from here https://github.com/vanilla/jsConnectPHP

Would be willing to donate for help getting this working.

Sponsor our Newsletter | Privacy Policy | Terms of Service