Created
October 10, 2018 19:30
-
-
Save ioness/8553daf63792b7b8d531d03fc02d6c6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function _successfulHybridauth($provider, $incomingProfile){ | |
// #1 - check if user already authenticated using this provider before | |
$this->SocialProfile->recursive = -1; | |
$existingProfile = $this->SocialProfile->find('first', array( | |
'conditions' => array('social_network_id' => $incomingProfile['SocialProfile']['social_network_id'], 'social_network_name' => $provider) | |
)); | |
if (!empty($existingProfile)) { | |
if (empty($existingProfile['SocialProfile']['user_id'])) { | |
$this->_doSocialLogin($existingProfile); | |
} | |
else { | |
// #2 - if an existing profile is available, then we set the user as connected and log them in | |
$user = $this->User->find('first', array( | |
'conditions' => array('id' => $existingProfile['SocialProfile']['user_id']) | |
)); | |
if (empty($user)) { | |
// Tiene un user_id asignado pero esta mal | |
} | |
$this->_doSocialLogin($existingProfile); | |
} | |
} | |
else { | |
if ($this->Auth->loggedIn()) { | |
$this->redirect($this->Auth->redirectUrl()); | |
} else { | |
if($this->SocialProfile->save($incomingProfile)) { | |
// el perfil se guardo correctamente | |
} | |
$this->_doSocialLogin($incomingProfile); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment