crugeconnector remote login in a yii framework application

CrugeConnector ΒΆ

Remote Login using Google, Facebook and others (extensible) for Yii Framework.


Christian Salazar H.


full wiki, documentation & installation:

(Source Code & Comments in English)

Screen Shot:

CrugeConnector Screen Capture

Quick Setup:

1- in protected/config/main.php, under 'imports' key: ~~~ 'application.extensions.crugeconnector.*', ~~~ 2- in protected/config/main.php, under 'components' key: ~~~

			// required by crugeconnector:
			// required by remote interface:
			'scope'=>'email, read_stream',
			// required by crugeconnector:
			// required by remote interface:
			// required by crugeconnector:
			// required by remote interface:
3- in protected/controllers/siteContoller.php (by default)
public function actions()
	return array(
		// ADD THIS:

// and this actions:

public function actionLoginSuccess($key){

	$loginData = Yii::app()->crugeconnector->getStoredData();
	// loginData: remote user information in JSON format.

	$info = $loginData;
	$this->renderText('<h1>Welcome!</h1><p>'.$info.'</p> key='.$key);

public function actionLoginError($key, $message=''){
	$this->renderText('<h1>Login Error</h1><p>'.$message.'</p> key='.$key);
4- insert the component into your protected/views/site/login view:
<?php if(Yii::app()->crugeconnector->hasEnabledClients){ ?>
<div class='crugeconnector'>
	<span>Use your Facebook or Google account:</span>
		$cc = Yii::app()->crugeconnector;
		foreach($cc->enabledClients as $key=>$config){
			$image = CHtml::image($cc->getClientDefaultImage($key));
			echo "<li>".CHtml::link($image,
<?php } ?>
5- create a callback (one for google and another one for facebook)

<?php // SAVE AS yourapp/facebook-callback.php, review your config main settings, must match.


// USE THIS WHEN URL MANAGER IS ACTIVATED, must match your URL rules: // DONT FORGET "?" at the end. // $url = "index.php/site/crugeconnector/crugekey/facebook/crugemode/callback?";

// USE THIS WHEN YOU ARE NOT USING URL MANAGER: // $url = "index.php?r=/site/crugeconnector&crugekey=facebook&crugemode=callback";

// common code: foreach($_GET as $key=>$val)

$url .= "&".$key."=".urlencode($val);

header("Location: ".$url); ~~~

0 0
Yii Version: 1.1
License: BSD-2-Clause
Category: Auth
Tags: Auth
Developed by: bluyell
Created on: Aug 26, 2014
Last updated: 9 years ago


show all

Related Extensions