Codoforum related discussions
SSO Problem

I've fill the var $account with my vars, but ihave just the index for reg/login and etc and its dosent work.

here is my client.php

<?php

/**
 * 
 * You do not have to edit sso.php file
 * 
 * This file/code should get executed when Codoforum sends a request
 * to the path <sso get user path> as defined in SSO plugin settings
 * in Codoforum backend
 * 
 * 
 */

require 'sso.php';

/**
 * 
 * The SSO client id and secret MUST be same as that set in the Codoforum
 * SSO plugin settings
 */
$settings = array(

  "client_id" => 'dbzforum',
  "secret" => 'Xe24!rf',
  "timeout" => 12000  
);

$sso = new codoforum_sso($settings);

$account = array();

/**
 * 
 * Here comes your logic to check if the user is logged in or not.
 * A simple example would be using PHP SESSION
 */
if (USER_IS_LOGGED_IN) {

    $account['uid'] = $personagem['id']; //Your logged in user's userid
    $account['name'] = $personagem['nome']; //Your logged in user's username
    $account['mail'] = $conta['email']; //Your logged in user's email id
    $account['avatar'] = ''; //not used as of now
}

$sso->output_jsonp($account); //output above as JSON back to Codoforum
exit();
I&#039;ve fill the var $account with my vars, but ihave just the index for reg/login and etc and its dosent work. here is my client.php ```` &lt;?php /** * * You do not have to edit sso.php file * * This file/code should get executed when Codoforum sends a request * to the path &lt;sso get user path&gt; as defined in SSO plugin settings * in Codoforum backend * * */ require &#039;sso.php&#039;; /** * * The SSO client id and secret MUST be same as that set in the Codoforum * SSO plugin settings */ $settings = array( &quot;client_id&quot; =&gt; &#039;dbzforum&#039;, &quot;secret&quot; =&gt; &#039;Xe24!rf&#039;, &quot;timeout&quot; =&gt; 12000 ); $sso = new codoforum_sso($settings); $account = array(); /** * * Here comes your logic to check if the user is logged in or not. * A simple example would be using PHP SESSION */ if (USER_IS_LOGGED_IN) { $account[&#039;uid&#039;] = $personagem[&#039;id&#039;]; //Your logged in user&#039;s userid $account[&#039;name&#039;] = $personagem[&#039;nome&#039;]; //Your logged in user&#039;s username $account[&#039;mail&#039;] = $conta[&#039;email&#039;]; //Your logged in user&#039;s email id $account[&#039;avatar&#039;] = &#039;&#039;; //not used as of now } $sso-&gt;output_jsonp($account); //output above as JSON back to Codoforum exit(); ````
edited Dec 11 '16 at 6:58 pm

The below line is incorrect

if (USER_IS_LOGGED_IN) {

You should put some logic to check this condition

The below line is incorrect ``` if (USER_IS_LOGGED_IN) { ``` You should put some logic to check this condition

The below line is incorrect

if (USER_IS_LOGGED_IN) {

You should put some logic to check this condition

I need put sql connection and Sesseion for my vars ?

&gt;The below line is incorrect &gt;``` &gt;if (USER_IS_LOGGED_IN) { &gt;``` &gt;You should put some logic to check this condition I need put sql connection and Sesseion for my vars ?

When a user logs in, you might have saved his information like userid or username in SESSION.

So you just need to check for that here to make sure that the code inside if block is executed only for logged in users.

Example code:

if(isset($_SESSION['userid'])) {
When a user logs in, you might have saved his information like userid or username in SESSION. So you just need to check for that here to make sure that the code inside if block is executed only for logged in users. Example code: ``` if(isset($_SESSION[&#039;userid&#039;])) { ```
252
3
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft