Yii Framework Forum: [MODULE] HybridAuth - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

[MODULE] HybridAuth Rate Topic: ***** 2 Votes

#81 User is offline   bonnie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 08-February 11

Posted 20 September 2012 - 08:30 PM

View Postmarkvr, on 17 September 2012 - 04:27 PM, said:

I wasn't even aware Yii had CSRF protection built in, I'll have a look.



This is by design because you won't neccesarily get those from the provider, so the user is given a chance to choose their username etc.


Here is what am getting http://www.sitename....er=Facebook#_=_
Look at the url this is after logging in with facebook then redirects to my site. Also it gives me a form to register and am already a registered user in my site.
0

#82 User is offline   Eduardo Leiva 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 30-January 11

Posted 21 September 2012 - 05:06 PM

Hi all,

I am trying that the user never disconnects ( 1 month ) from my app so i extend session time.

Yii::app()->user->login($identity,2628000); // One month
And php.ini session_lifeTime too. 


But after a time facebook token dies and no more info is retrieved from FB .

I found that this token expire after two hours.
How i can manage that?


Thanks in advance.
0

#83 User is offline   Sergo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 01-October 12

Posted 02 October 2012 - 04:24 PM

Nice module, keep up the good work!


I test-drove it (Facebook only) today. Here are my installation steps. As I am very new to Yii I had a bit of the struggle. Hope this helps somebody else as well.

1. Created a new facebook app
According to: hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html). Important to set your Site url in Facebook exactly the same as in config file baseUrl parameter.

2. Created a Yii skeleton app.

3. Made changes in protected/config/main.php
Uncommented the url manager, added .htaccess (see www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config)file to website root dir.

4. Created 2 new tables in default (testdrive) sqlite database:

CREATE TABLE [ha_logins] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[userId] int(11) NOT NULL,
[loginProvider] varchar(50) NOT NULL,
[loginProviderIdentifier] varchar(100) NOT NULL);

I know, MySQL table, provided in the extension description, had a lot more keys and indexes.

For User model:

CREATE TABLE [user] (
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[username] VARCHAR(128) NOT NULL,
[password] VARCHAR(128),
[email] VARCHAR(128) NOT NULL);

(Notice the password can be null)


5. Create a User model (either with gii or yiic)
The user module does not work normally yet, this is only for testing hybridauth. For exampl see: www.yiiframework.com/doc/blog/1.1/en/prototype.auth

6. Paste the configuration data into main.php
Make required changes (baseUrl, app-ids, and secrets).

Important! If you are using Linux server, change provider indexes first letter to upper case (see the 1st comment on the extension page).

7. Unpack extension to newly created protected/modules dir


Go to: your-path/dir/hybridauth and click on facebook icon.
1

#84 User is offline   compugator 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 01-May 11

Posted 30 October 2012 - 04:28 PM

View Postmarkvr, on 17 September 2012 - 04:30 PM, said:

Sorry, yes you probably do. I'll investigate URLManager, I wasn't really aware of it before.


I know this is probably an easy question to answer, but I cannot figure out what I didn't do during the setup. It looks close to what you were discussing, but apparently you are able to get farther than I do.

I copied the widget from the extension page
<?php $this->widget('application.modules.hybridauth.widgets.renderProviders'); ?>



and added the module to my config file and tried to add the widget to one of my pages, but I keep getting the following error when I click on one of the social icons:
The requested URL /hybridauth/default/login/ was not found on this server.


It seems my code cannot "see" the hybridauth module or the default controller in the module. I am not sure what else to change for this.

Sorry if this is a stupid question.
0

#85 User is offline   compugator 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 01-May 11

Posted 30 October 2012 - 09:03 PM

View Postcompugator, on 30 October 2012 - 04:28 PM, said:

I know this is probably an easy question to answer, but I cannot figure out what I didn't do during the setup. It looks close to what you were discussing, but apparently you are able to get farther than I do.

I copied the widget from the extension page
<?php $this->widget('application.modules.hybridauth.widgets.renderProviders'); ?>



and added the module to my config file and tried to add the widget to one of my pages, but I keep getting the following error when I click on one of the social icons:
The requested URL /hybridauth/default/login/ was not found on this server.


It seems my code cannot "see" the hybridauth module or the default controller in the module. I am not sure what else to change for this.

Sorry if this is a stupid question.


Ok, I just saw where you have to add index.php/ to the base_url. It got me past that point and to the login at least.
0

#86 User is offline   damogallagher 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 02-November 12

Posted 02 November 2012 - 12:05 PM

View Postcompugator, on 30 October 2012 - 09:03 PM, said:

Ok, I just saw where you have to add index.php/ to the base_url. It got me past that point and to the login at least.


Hi

What is the correct url for accessing the content?
I tried with and without the index.php but with no joy

None of these urls worked, I keep getting a page not found.
I also tried this out on a box that had a dns url assigned to it but that didnt work either

I tried the sample a few times, with blank yii projects but no good


Any assistance on this is greatly appreciated
0

#87 User is offline   Jgsaw 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 01-March 11

Posted 11 November 2012 - 12:50 PM

Great extension. My site already has a registration system with User table and UserProfile table so I changed it slightly to call a custom Registration page so you can implement your own registration. Might be worth including something like this in future releases?

Extract Register (createUser) from _doLogin into its own method with protected access. Also make _linkProvider protected

DefaultController.php
	private function _doLogin() {
		....
		} else if ($identity->errorCode == RemoteUserIdentity::ERROR_USERNAME_INVALID) {
			// They have authenticated to their provider but we don't have a matching HaLogin entry
			if (Yii::app()->user->isGuest) {
				$this->registerUser($identity);
			} else {
				// They are already logged in, link their user account with new provider
				...
			}
		}
	}

	/**
	 * Overridable method to display a custom Registration page if desired
	 * Overrides should make sure to call the following method to link the user to the provider 
	 * 	$this->_linkProvider($identity);
	 * 
	 * @param RemoteUserIdentity $identity
	 */
	protected function registerUser($identity) {
		// They aren't logged in => display a form to choose their username & email
		// (we might not get it from the provider)
		if ($this->module->withYiiUser == true) {
			Yii::import('application.modules.user.models.*');
		} else {
			Yii::import('application.models.*');
		}
		
		$user = new User;
		if (isset($_POST['User'])) {
			//Save the form
			$user->attributes = $_POST['User'];
		
			if ($user->validate() && $user->save()) {
				if ($this->module->withYiiUser == true) {
					$profile = new Profile();
					$profile->first_name='firstname';
					$profile->last_name='lastname';
					$profile->user_id=$user->id;
					$profile->save();
				}
		
				$identity->id = $user->id;
				$identity->username = $user->username;
				$this->_linkProvider($identity);
				$this->_loginUser($identity);
			} // } else { do nothing } => the form will get redisplayed
		} else {
			//Display the form with some entries prefilled if we have the info.
			if (isset($identity->userData->email)) {
				$user->email = $identity->userData->email;
				$email = explode('@', $user->email);
				$user->username = $email[0];
			}
		}
		
		$this->render('createUser', array(
				'user' => $user,
		));
	}



Then create a new Controller that extends DefaultController and override the method to display your onw custom Registration page

CustomController.php
Yii::import('application.modules.hybridauth.controllers.DefaultController');

class CustomController extends DefaultController {
	
	protected function registerUser($identity) {
            // Your custom Code here
        }
}


Then set the default controller in the Module config

main.php
'hybridauth' => array(
    .....
    'defaultController'=>'custom',
    ....
),


And lastly i had to update render providers widget to use the defaultController as specified in the module rather than the currently hardcoded default controller

providers.php
<?php $controller = Yii::app()->getModule('hybridauth')->defaultController; ?>
....
<form action="<?php echo $this->config['baseUrl'];?>/<?php echo $controller; ?>/login/" method="get" id="hybridauth-openid-form" >
....
<form action="<?php echo $this->config['baseUrl'];?>/<?php echo $controller; ?>/unlink" method="post" id="hybridauth-unlink-form" >
....
<a id="hybridauth-<?php echo $provider ?>" href="<?php echo $baseUrl?>/<?php echo $controller; ?>/login/?provider=<?php echo $provider ?>" >
....


Any suggestions/comments welcome!

Thanks
Ross
1

#88 User is offline   Jgsaw 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 01-March 11

Posted 11 November 2012 - 04:26 PM

One other thing, if your server runs on unix the config is case sensitive! I had 'facebook'=> array() but the provider files called Facebook.php which threw an error. Had to change it to 'Facebook'=> array()
1

#89 User is offline   maxtor 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 23-January 12

Posted 20 November 2012 - 04:50 AM

When a page provider, I press "Cancel", I redirect to the page:
_http://site/hybridauth/default/login/?provider=provider

Quote

Error – 500
include(DefaultController.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

The error occurs here:
/protected/modules/hybridauth/Hybrid/Storage.php(25):
return unserialize( $_SESSION["HA::STORE"][$key] ); 

Please help
0

#90 User is offline   subdee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 24-January 11
  • Location:Den Haag

Posted 30 November 2012 - 04:57 AM

Hi

I am using your plugin to integrate several social logins on a project, including Facebook.

I am facing a problem that I can't trace anywhere and that is that even if I set display => popup for FB, it opens the facebook connect page normally instead of in a popup which results in the user leaving the website.

Here's what I use in my view:

<?php $this->widget('application.modules.hybridauth.widgets.renderProviders'); ?>


and here's what I have in my config:

"Facebook" => array(
                    "enabled" => true,
                    "keys" => array("id" => "XXXXXX", "secret" => "XXXXXX"),
                    "scope" => "",
                    "display" => "popup"
                ),


I have a feeling that something might have to be changed in the widget view to account for this, but anything I've tried didn't work. Shouldn't there be some sort of JS registered for Facebook?
0

#91 User is offline   Harimau 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 03-July 12

Posted 02 December 2012 - 11:33 PM

View Postmaxtor, on 20 November 2012 - 04:50 AM, said:

When a page provider, I press "Cancel", I redirect to the page:
_http://site/hybridauth/default/login/?provider=provider

The error occurs here:
/protected/modules/hybridauth/Hybrid/Storage.php(25):
return unserialize( $_SESSION["HA::STORE"][$key] ); 

Please help


I have the same problem. If I try to login with Facebook, then press cancel on the Facebook auth screen I see this error. I'll continue to investigate but if anyone already has a solution...?

This issue didn't occur in an older version of this module that I used before.
0

#92 User is offline   vincenze 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 06-December 12

Posted 06 December 2012 - 08:11 PM

'import'=>array(
'application.models.*',
'application.components.*',
//for hybridauth
'application.modules.hybridauth.controllers.*',
)

Add the path to DefaultController.php for the autoloader into the config file.
Maybe, there is a better solution with require.
0

#93 User is offline   Harimau 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 03-July 12

Posted 06 December 2012 - 09:12 PM

View Postvincenze, on 06 December 2012 - 08:11 PM, said:

'import'=>array(
'application.models.*',
'application.components.*',
//for hybridauth
'application.modules.hybridauth.controllers.*',
)

Add the path to DefaultController.php for the autoloader into the config file.
Maybe, there is a better solution with require.


I had already tried that - it didn't work. This turned out to be a problem with the sessions used in Hybridauth being overwritten by the sessions in Yii. The module doesn't seem to work at all with Yii sessions auto-starting. It works fine with sessions turned off.
0

#94 User is offline   Fahd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 17-August 11

Posted 07 December 2012 - 10:29 AM

I'm getting an error "include(DefaultController.php): failed to open stream: No such file or directory" and some weird characters get added to the url "#_=_". I'm testing this on localhost and using just facebook. I understand this has been reported by other members in the thread too, so has anyone found out the solution to this and what's causing this?
0

#95 User is offline   vincenze 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 06-December 12

Posted 07 December 2012 - 07:44 PM

It works for me with the import line. My sessions are autostarted.

I've updated the directory Hybrid with the files from hybridauth.sourceforge.net/
Google works. Now, they use OAuth for Yahoo, I need to verify the config for it.
0

#96 User is offline   fonko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-December 12

Posted 12 December 2012 - 01:52 PM

hey guys how much time do you think it takes to implement this extension only to provide facebook connect to my site? i need to estimate an amount of time for my project. i only have name email password country and date of birth in my login form. And im brand new (1 month) with yii
0

#97 User is offline   ravish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-December 12

Posted 18 December 2012 - 07:01 AM

View PostFahd, on 07 December 2012 - 10:29 AM, said:

I'm getting an error "include(DefaultController.php): failed to open stream: No such file or directory" and some weird characters get added to the url "#_=_". I'm testing this on localhost and using just facebook. I understand this has been reported by other members in the thread too, so has anyone found out the solution to this and what's causing this?


Kindly follow the vincenze instructions, the default controller error will not occur. It is working fine for me with those instructions. Refer #92
0

#98 User is offline   ravish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-December 12

Posted 18 December 2012 - 07:07 AM

View Postfonko, on 12 December 2012 - 01:52 PM, said:

hey guys how much time do you think it takes to implement this extension only to provide facebook connect to my site? i need to estimate an amount of time for my project. i only have name email password country and date of birth in my login form. And im brand new (1 month) with yii


Maximum 2 hours.
0

#99 User is offline   ravish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-December 12

Posted 18 December 2012 - 07:10 AM

View Postmaxtor, on 20 November 2012 - 04:50 AM, said:

When a page provider, I press "Cancel", I redirect to the page:
htt://site/hybridauth/default/login/?provider=provider

The error occurs here:
/protected/modules/hybridauth/Hybrid/Storage.php(25):
return unserialize( $_SESSION["HA::STORE"][$key] ); 

Please help


Plz refer #92
0

#100 User is offline   nirmalroka 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 10-July 12
  • Location:Kathmandu Nepal

Posted 18 December 2012 - 11:50 PM

When i tried to update status with hybridauth it throws error

Array ( [Post] => Array ( [receiver_type] => 0 [receiver_id] => 2 [message] => faf ) [socialmedia] => Array ( [facebook] => 1 [twitter] => 1 [linkedin] => 1 ) )
Exception

Update user status update failed! LinkedIn returned an error.
0

Share this topic:


  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users