public function outputSSO($userId = 0)
 {
     $result = "";
     $settings = craft()->plugins->getPlugin('vanillaforums')->getSettings();
     $data = array();
     $currentUser = craft()->userSession->user;
     if ($currentUser) {
         $data['uniqueid'] = $currentUser->id;
         if (craft()->config->get('useEmailAsUsername')) {
             $data['name'] = $currentUser->getFullName();
         } else {
             $data['name'] = $currentUser->username;
         }
         $data['email'] = $currentUser->email;
         if ($currentUser->getPhotoUrl()) {
             $data['photourl'] = $currentUser->getPhotoUrl();
         }
     }
     $vanillaforumsClientID = $settings['vanillaforumsClientID'];
     $vanillaforumsSecret = $settings['vanillaforumsSecret'];
     $secure = true;
     //ob_start(); // Start output buffering
     \WriteJsConnect($data, $_GET, $vanillaforumsClientID, $vanillaforumsSecret, $secure);
     //$result = ob_get_contents(); // Store buffer in variable
     //ob_end_clean();
     return $result;
 }
Esempio n. 2
0
$signedIn = true;
// 2. Grab the current user from your session management system or database here.
// prepare image file for display
/*$url_prefix = $setting['site_full_url'];
  $test_imgfile_path = $setting['profile_img_dir'].$_COOKIE['signed_in_id'].$setting['profile_img_ext'];
  if(file_exists($test_imgfile_path)) {
      $imgfile_path = $url_prefix.$test_imgfile_path;
  }
  else {
      $imgfile_path = $url_prefix.$setting['profile_img_dir'].'blank-user.png';
  }*/
// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();
if ($signedIn) {
    // CHANGE THESE FOUR LINES.
    $user['uniqueid'] = $_SESSION["id"];
    $user['name'] = $_SESSION["name"];
    $user['email'] = $_SESSION["email"];
    $user['photourl'] = '';
}
// 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 = 'md5';
$count = WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
echo $count;
// for full page forum
//JsSSOString($user, $clientID, $secret);  // add this line if using an embedded forum (remove if not embedded)
if ($count != 0) {
    header("Location:http://localhost/mithra/forums/index.php?p=/");
}
 /**
  * 
  * @param Gdn_Controller $Sender
  * @param array $Args 
  */
 public function ProfileController_JsConnect_Create($Sender, $Args = array())
 {
     include_once dirname(__FILE__) . '/functions.jsconnect.php';
     $client_id = $Sender->Request->Get('client_id', 0);
     $Provider = self::GetProvider($client_id);
     $client_id = GetValue('AuthenticationKey', $Provider);
     $Secret = GetValue('AssociationSecret', $Provider);
     if (Gdn::Session()->IsValid()) {
         $User = ArrayTranslate((array) Gdn::Session()->User, array('UserID' => 'UniqueID', 'Name', 'Email', 'PhotoUrl', 'DateOfBirth', 'Gender'));
         //         $Sfx = 'F';
         //         $User['UniqueID'] .= $Sfx;
         //         $User['Name'] .= $Sfx;
         //         $User['Email'] = str_replace('@', '+'.$Sfx.'@', $User['Email']);
         if (!$User['PhotoUrl'] && function_exists('UserPhotoDefaultUrl')) {
             $User['PhotoUrl'] = Url(UserPhotoDefaultUrl(Gdn::Session()->User), TRUE);
         }
     } else {
         $User = array();
     }
     ob_clean();
     WriteJsConnect($User, $Sender->Request->Get(), $client_id, $Secret, GetValue('HashType', $Provider, TRUE));
     exit;
 }
Esempio n. 4
0
<?php

/**
 * Single Sign-on functions.
 */
/**
 * Check to see if we should kill processing and display information for Vanilla
 */
$VFRequest = vf_get_value('VFRequest', $_GET);
switch ($VFRequest) {
    // Show the signed in user
    case 'connect':
        require_once dirname(__FILE__) . '/functions.jsconnect.php';
        $user = vf_get_user();
        $options = get_option(VF_OPTIONS_NAME);
        $clientID = vf_get_value('sso-clientid', $options, '');
        $secret = vf_get_value('sso-secret', $options, '');
        WriteJsConnect($user, $_GET, $clientID, $secret, true);
        exit;
        break;
        // Generate a secret to be used for security.
    // Generate a secret to be used for security.
    case 'generate-secret':
        echo md5(time());
        exit;
        break;
}