src/controllers/SocialRegisterController.php
public function attach($provider_name) {
        $response = null;


        $profile = null;
        $identifier = $this->auth($provider_name, $profile);
        if(!$this->checkRegistered($provider_name, $identifier)) {

            $id = Auth::user()->getAuthIdentifier();

            $login = $this->login_repository->create();
            $login->setProvider($provider_name);
            $login->setIdentifier($identifier);
            $login->setUser($id);

            if($this->login_repository->save($login)) {
	            $providers = SocialAuth::getConnectedProviders();
	            $socialProfile = $providers[$provider_name]->getProfile();
	            Event::fire('social-auth.attach', ['user' => Auth::user(),  'provider' => $provider_name, 'profile' => $socialProfile]);
                $response = Redirect::back()->with(['message' => trans('social-auth::user.account attach success',
                    ['provider' => $provider_name, 'accountname' => $socialProfile->getDisplayName()])]);
            } else {
                $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account attach fail', ['accoutnname' => $profile->displayName])]);
            }

        } else {
            $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]) ]);
        }

        return $response;
    }
public function attach($provider_name) {
        $response = null;


        $profile = null;
        $identifier = $this->auth($provider_name, $profile);
        if(!$this->checkRegistered($provider_name, $identifier)) {

            $id = Auth::user()->getAuthIdentifier();

            $login = $this->login_repository->create();
            $login->setProvider($provider_name);
            $login->setIdentifier($identifier);
            $login->setUser($id);

            if($this->login_repository->save($login)) {
	            $providers = SocialAuth::getConnectedProviders();
	            $socialProfile = $providers[$provider_name]->getProfile();
	            Event::fire('social-auth.attach', ['user' => Auth::user(),  'provider' => $provider_name, 'profile' => $socialProfile]);
                $response = Redirect::back()->with(['message' => trans('social-auth::user.account attach success',
                    ['provider' => $provider_name, 'accountname' => $socialProfile->getDisplayName()])]);
            } else {
                $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account attach fail', ['accoutnname' => $profile->displayName])]);
            }

        } else {
            $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]) ]);
        }

        return $response;
    }
public function attach ( $ provider_name ) { $ response = null ; $ profile = null ; $ identifier = $ this -> auth ( $ provider_name , $ profile ) ; if ( ! $ this -> checkRegistered ( $ provider_name , $ identifier ) ) { $ id = Auth :: user ( ) -> getAuthIdentifier ( ) ; $ login = $ this -> login_repository -> create ( ) ; $ login -> setProvider ( $ provider_name ) ; $ login -> setIdentifier ( $ identifier ) ; $ login -> setUser ( $ id ) ; if ( $ this -> login_repository -> save ( $ login ) ) { $ providers = SocialAuth :: getConnectedProviders ( ) ; $ socialProfile = $ providers [ $ provider_name ] -> getProfile ( ) ; Event :: fire ( 'social-auth.attach' , [ 'user' => Auth :: user ( ) , 'provider' => $ provider_name , 'profile' => $ socialProfile ] ) ; $ response = Redirect :: back ( ) -> with ( [ 'message' => trans ( 'social-auth::user.account attach success' , [ 'provider' => $ provider_name , 'accountname' => $ socialProfile -> getDisplayName ( ) ] ) ] ) ; } else { $ response = Redirect :: back ( ) -> withErrors ( [ 'message' => trans ( 'social-auth::user.account attach fail' , [ 'accoutnname' => $ profile -> displayName ] ) ] ) ; } } else { $ response = Redirect :: back ( ) -> withErrors ( [ 'message' => trans ( 'social-auth::user.account already registered' , [ 'accountname' => $ profile -> displayName ] ) ] ) ; } return $ response ; }
Attempt to login to a social-auth provider
If successful, attach the social-auth user to the currently logged in user on this system

@param $provider_name
@return \Illuminate\Http\RedirectResponse|null
Attempt to login to a social - auth provider If successful attach the social - auth user to the currently logged in user on this system