[install] hoauth and yii user extension - SleepWalker/hoauth GitHub Wiki

Install hoauth and yii-user extension

NOTE: You should use yii-user from github, because on the yii's website is old version.

The installing of hoauth with support of yii-user extension is even easier, than with no yii-user module, so follow the steps:

After you have downloaded and extracted hoauth files in extension directory. Go to protected/modules/user/controllers/LoginController.php and add actions() method:

  public function actions()
  {
    return array(
      'oauth' => array(
        'class'=>'ext.hoauth.HOAuthAction',
      ),
      'oauthadmin' => array(
        'class'=>'ext.hoauth.HOAuthAdminAction',
      ),
    );
  }

Now you can edit your login page view (protected/modules/user/views/user/login.php) and add somewhere the sign in widget:

<?php $this->widget('ext.hoauth.widgets.HOAuth'); ?>

And the last step is to configure HybridAuth. Open the following link: http://yoursite.com/user/login/oauthadmin in your browser and follow instructions. Endpoint URL should be: http://yoursite.com/user/login/oauth . After you will be ready with configuration, don't forget to delete oauthadmin action or add the following access rules in your LoginController:

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', 
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('oauthadmin'),
				'users'=>UserModule::getAdmins(),
			),
			array('deny',  // deny all users
                                'actions'=>array('oauthadmin'),
				'users'=>array('*'),
			),
		);
	}

Available Callbacks

To make you able to customize the behavior of hoauth, it is provide some useful callbacks. Here the list of them:

  • Controller::hoauthCheckAccess($user)
  • Controller::hoauthAfterLogin($user)

More about callbacks

NOTES:

Make SURE that you have php5-curl and necessary curl libraries installed on your server!!