public function associateAccount(Users $user, \Hybridauth\User\Profile $socialProfile, $socialNetwork)
    {
        //si no esta asociada tu uenta
        if (!$this->existSocialProfile($socialProfile, $socialNetwork)) {
            $source = Sources::findFirst(['title = :title:', 'bind' => ['title' => strtolower($socialNetwork)]]);

            $userLinkedSources = new self();
            $userLinkedSources->users_id = $user->getId();
            $userLinkedSources->source_id = $source->source_id;
            $userLinkedSources->source_users_id = $socialProfile->identifier;
            $userLinkedSources->source_username = $socialProfile->identifier;

            //since the user is registration via a social network and it was sucessful we need to activate its account
            if (!$user->user_active) {
                $user->user_active = 1;
                $user->update();
            }

            if (!$userLinkedSources->save()) {
                throw new \Exception($userLinkedSources->getMessages()[0]);
            }

            return true;
        }

        return false;
    }
public function associateAccount(Users $user, \Hybridauth\User\Profile $socialProfile, $socialNetwork)
    {
        //si no esta asociada tu uenta
        if (!$this->existSocialProfile($socialProfile, $socialNetwork)) {
            $source = Sources::findFirst(['title = :title:', 'bind' => ['title' => strtolower($socialNetwork)]]);

            $userLinkedSources = new self();
            $userLinkedSources->users_id = $user->getId();
            $userLinkedSources->source_id = $source->source_id;
            $userLinkedSources->source_users_id = $socialProfile->identifier;
            $userLinkedSources->source_username = $socialProfile->identifier;

            //since the user is registration via a social network and it was sucessful we need to activate its account
            if (!$user->user_active) {
                $user->user_active = 1;
                $user->update();
            }

            if (!$userLinkedSources->save()) {
                throw new \Exception($userLinkedSources->getMessages()[0]);
            }

            return true;
        }

        return false;
    }
public function associateAccount ( Users $ user , \ Hybridauth \ User \ Profile $ socialProfile , $ socialNetwork ) { //si no esta asociada tu uenta if ( ! $ this -> existSocialProfile ( $ socialProfile , $ socialNetwork ) ) { $ source = Sources :: findFirst ( [ 'title = :title:' , 'bind' => [ 'title' => strtolower ( $ socialNetwork ) ] ] ) ; $ userLinkedSources = new self ( ) ; $ userLinkedSources -> users_id = $ user -> getId ( ) ; $ userLinkedSources -> source_id = $ source -> source_id ; $ userLinkedSources -> source_users_id = $ socialProfile -> identifier ; $ userLinkedSources -> source_username = $ socialProfile -> identifier ; //since the user is registration via a social network and it was sucessful we need to activate its account if ( ! $ user -> user_active ) { $ user -> user_active = 1 ; $ user -> update ( ) ; } if ( ! $ userLinkedSources -> save ( ) ) { throw new \ Exception ( $ userLinkedSources -> getMessages ( ) [ 0 ] ) ; } return true ; } return false ; }
Funcion que registra al user de la red social, al sistema.
Si ya esta registrado lo logea

@param Hybridauth\Entity\Profile $socialProfile
@param string $socialNetwork
@return Users
Funcion que registra al user de la red social al sistema . Si ya esta registrado lo logea