src/Traits/TakiSocial.php
public function getOauthCallback($service)
    {
        $user = \Socialite::driver($service)->user();

        $email = $user->getEmail();

        $dbUser = \User::where('email', $email)->first();
        if (!$dbUser) {
            $userInfo = [
                'name'                     => $user->getName(),
                config('taki.field.email') => $user->getEmail(),
                'avatar'                   => $user->getAvatar(),
                'provider'                 => $service,
            ];

            if (config('taki.social.password_required') || config('taki.social.username_required')) {
                \Taki::saveOauthUser($service, $user->getEmail());
                return redirect($this->getOauthCompletePath())->with($userInfo);
            } else {
                $userInfo['password']                    = false;
                $userInfo['token']                       = false;
                $userInfo[config('taki.field.username')] = $this->generateUsername($service, $user);
                $dbUser                                  = $this->create($userInfo);
            }
        }

        Auth::login($dbUser, true);
        return redirect()->intended();
    }
public function getOauthCallback($service)
    {
        $user = \Socialite::driver($service)->user();

        $email = $user->getEmail();

        $dbUser = \User::where('email', $email)->first();
        if (!$dbUser) {
            $userInfo = [
                'name'                     => $user->getName(),
                config('taki.field.email') => $user->getEmail(),
                'avatar'                   => $user->getAvatar(),
                'provider'                 => $service,
            ];

            if (config('taki.social.password_required') || config('taki.social.username_required')) {
                \Taki::saveOauthUser($service, $user->getEmail());
                return redirect($this->getOauthCompletePath())->with($userInfo);
            } else {
                $userInfo['password']                    = false;
                $userInfo['token']                       = false;
                $userInfo[config('taki.field.username')] = $this->generateUsername($service, $user);
                $dbUser                                  = $this->create($userInfo);
            }
        }

        Auth::login($dbUser, true);
        return redirect()->intended();
    }
public function getOauthCallback ( $ service ) { $ user = \ Socialite :: driver ( $ service ) -> user ( ) ; $ email = $ user -> getEmail ( ) ; $ dbUser = \ User :: where ( 'email' , $ email ) -> first ( ) ; if ( ! $ dbUser ) { $ userInfo = [ 'name' => $ user -> getName ( ) , config ( 'taki.field.email' ) => $ user -> getEmail ( ) , 'avatar' => $ user -> getAvatar ( ) , 'provider' => $ service , ] ; if ( config ( 'taki.social.password_required' ) || config ( 'taki.social.username_required' ) ) { \ Taki :: saveOauthUser ( $ service , $ user -> getEmail ( ) ) ; return redirect ( $ this -> getOauthCompletePath ( ) ) -> with ( $ userInfo ) ; } else { $ userInfo [ 'password' ] = false ; $ userInfo [ 'token' ] = false ; $ userInfo [ config ( 'taki.field.username' ) ] = $ this -> generateUsername ( $ service , $ user ) ; $ dbUser = $ this -> create ( $ userInfo ) ; } } Auth :: login ( $ dbUser , true ) ; return redirect ( ) -> intended ( ) ; }
Create user or log the user in after success authentication

@param type $service
@return type
Create user or log the user in after success authentication