Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After playing with it for awhile, I am going to answer my own question. This is how I make it to work, so you can change it according to your needs. </p> <p>Note: I use a userController instead of the siteController and please follow all the instructions in the respective extension page.</p> <p>If you used the two plugins as indicated above, then what you need to do next to make it work are the followings: (this is a step by step guide) <strong>But the most important steps are 2c and 3, they are the glue to both plugins</strong></p> <p>1) Have a login page that uses the OpenidSelector. Place it at views/user/login.php</p> <pre><code>&lt;?php $this-&gt;widget('application.extensions.openidProviders.openidProviders', array ( 'options' =&gt; array ( 'lang' =&gt; 'en', // 'demo' =&gt; 'js:true', 'cookie_expires' =&gt; 6*30, )));?&gt; </code></pre> <p>2) Setup actions to handle the selection from the openidSelector. I put this in the userController.</p> <p>a) In main config file.</p> <pre><code> 'components'=&gt;array( 'user'=&gt;array( // enable cookie-based authentication 'allowAutoLogin'=&gt;true, 'loginUrl' =&gt; array('/user/login'), //change the default login page ), </code></pre> <p>b) In userController file, add login and authenticate actions</p> <pre><code>array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=&gt;array('login', 'authenticate'), </code></pre> <p>Code for action #1 actionLogin - this is to trigger the login view page.</p> <pre><code>public function actionLogin() { // display the login form $this-&gt;render('login',array()); } </code></pre> <p>c) Code for action #2 actionAuthenticate - code modified from the LOID instruction page, this is to handle when an OpenIDProvider is selected in the login page.</p> <pre><code>public function actionAuthenticate () { // Put the Simple usage: code on // http://www.yiiframework.com/extension/loid here: // Code from loid Simple usage page. // START HERE $loid = Yii::app()-&gt;loid-&gt;load(); if (!empty($_GET['openid_mode'])) { if ($_GET['openid_mode'] == 'cancel') { $err = Yii::t('core', 'Authorization cancelled'); } else { try { echo $loid-&gt;validate() ? 'Logged in.' : 'Failed'; } catch (Exception $e) { $err = Yii::t('core', $e-&gt;getMessage()); } } if(!empty($err)) echo $err; } else { // **NOTE:Comment out this line from the loid sample page** // $loid-&gt;identity = "http://my.openid.identifier"; //Setting identifier // this openid_identifier is need after you click the openselector $loid-&gt;identity = $_GET['openid_identifier']; // CHANGE HERE $loid-&gt;required = array('namePerson/friendly', 'contact/email'); //Try to get info from openid provider $loid-&gt;realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; $loid-&gt;returnUrl = $loid-&gt;realm . $_SERVER['REQUEST_URI']; //getting return URL if (empty($err)) { try { $url = $loid-&gt;authUrl(); $this-&gt;redirect($url); } catch (Exception $e) { $err = Yii::t('core', $e-&gt;getMessage()); } } } // Code from loid Simple usage page. // END HERE } </code></pre> <p>3) Change the action URL to Authenticate in the openidProviders/views/main-en.php</p> <p>Change</p> <pre><code>form action="examples/consumer/try_auth.php" method="get" id="openid_form" </code></pre> <p>to</p> <pre><code>form action="authenticate" method="get" id="openid_form" </code></pre> <p>That should be it. Haven't tested failure case, only tested with google login.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload