I am currently in the process of trying to extend the cakeDC users plugin. It is proving relatively difficult to integrate this plugin with the plugin for Opauth located here:
https://github.com/uzyn/cakephp-opauth
For instance I want in my application the ability to register and login a user via facebook, google etc...
I have been attempting this with the google implementation and I am able to retrieve data back from Google through the opauth plugin. My issues lies with what do I do with this information now? If I want to register this user with my App, I don't know the next steps to do this...
This is what the data returned in the array looks like:
Array
(
[auth] => Array
(
[uid] => 1xxxxxxxxx1
[info] => Array
(
[name] => xxx xxx
[email] => xx.xx@xx.com
[first_name] => xx
[last_name] => xx
)
[credentials] => Array
(
[token] => #%*(&)(*&%)*^$^)($%
[expires] => 2013-08-09T19:23:10+00:00
)
[raw] => Array
(
[id] => 1XXXXXXXXXXXXX1
[email] => XXXX.XXXXX@XXXXX.com
[verified_email] => 1
[name] => XXX XXX
[given_name] => XXXX
[family_name] => XXXXX
[gender] => male
[locale] => en
[hd] => test.com
)
[provider] => Google
)
[timestamp] => 2013-08-09T18:23:11+00:00
[signature] => *#&$&$$&$&$&$&$$####
[validated] => 1
)
It doesnt seem to me that there is a password token that stays generated to compare with but that isnt even the current blocker. The blocker resides in how to register this information into the cakeDC users plugin extended class. Any help is greatly appreciated, and I am sure I am not the only developer out there curious how to extend this pluging to be integrated with the Opauth plugin.
EDITS: (** WORKING LOGIN CODE **)
public function beforeFilter() {
$this->Auth->Allow('opauth_complete');
}
public function opauth_complete() {
$user = $this->set('opauth_data', $this->request->data);
$loginUser = $this->User->find('first',
array('fields'=>array('User.*'),
'conditions'=>array('User.email'=>$this->request->data['auth']['info']['email'])));
if ($this->request->is('post')) {
if ($this->Auth->login($loginUser)) {
//return $this->redirect($this->Auth->redirect());
$this->Session->setFlash(__('You are logged in.'));
}else{
$this->Session->setFlash(__('You are currently not Authorized'));
}
}
}
The hangup seems to be on $this->Auth->login($loginUser); It find the user in the database, and yet it still wont authorize them through the google account.