public function loginOAuthUser(OAuthUserContract $user)
    {
        /** @noinspection PhpUndefinedFieldInspection */
        $responseBody = $user->accessTokenResponseBody;
        /** @noinspection PhpUndefinedFieldInspection */
        $token = $user->token;

        $dfUser = $this->createShadowOAuthUser($user);
        $dfUser->last_login_date = Carbon::now()->toDateTimeString();
        $dfUser->confirm_code = null;
        $dfUser->save();

        $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first();
        if (empty($map)) {
            OAuthTokenMap::create(
                [
                    'user_id'    => $dfUser->id,
                    'service_id' => $this->id,
                    'token'      => $token,
                    'response'   => $responseBody
                ]);
        } else {
            $map->update(['token' => $token, 'response' => $responseBody]);
        }
        Session::setUserInfoWithJWT($dfUser);
        $response = Session::getPublicInfo();
        $response['oauth_token'] = $token;
        if (isset($responseBody['id_token'])) {
            $response['id_token'] = $responseBody['id_token'];
        }

        return $response;
    }
public function loginOAuthUser(OAuthUserContract $user)
    {
        /** @noinspection PhpUndefinedFieldInspection */
        $responseBody = $user->accessTokenResponseBody;
        /** @noinspection PhpUndefinedFieldInspection */
        $token = $user->token;

        $dfUser = $this->createShadowOAuthUser($user);
        $dfUser->last_login_date = Carbon::now()->toDateTimeString();
        $dfUser->confirm_code = null;
        $dfUser->save();

        $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first();
        if (empty($map)) {
            OAuthTokenMap::create(
                [
                    'user_id'    => $dfUser->id,
                    'service_id' => $this->id,
                    'token'      => $token,
                    'response'   => $responseBody
                ]);
        } else {
            $map->update(['token' => $token, 'response' => $responseBody]);
        }
        Session::setUserInfoWithJWT($dfUser);
        $response = Session::getPublicInfo();
        $response['oauth_token'] = $token;
        if (isset($responseBody['id_token'])) {
            $response['id_token'] = $responseBody['id_token'];
        }

        return $response;
    }
public function loginOAuthUser ( OAuthUserContract $ user ) { /** @noinspection PhpUndefinedFieldInspection */ $ responseBody = $ user -> accessTokenResponseBody ; /** @noinspection PhpUndefinedFieldInspection */ $ token = $ user -> token ; $ dfUser = $ this -> createShadowOAuthUser ( $ user ) ; $ dfUser -> last_login_date = Carbon :: now ( ) -> toDateTimeString ( ) ; $ dfUser -> confirm_code = null ; $ dfUser -> save ( ) ; $ map = OAuthTokenMap :: whereServiceId ( $ this -> id ) -> whereUserId ( $ dfUser -> id ) -> first ( ) ; if ( empty ( $ map ) ) { OAuthTokenMap :: create ( [ 'user_id' => $ dfUser -> id , 'service_id' => $ this -> id , 'token' => $ token , 'response' => $ responseBody ] ) ; } else { $ map -> update ( [ 'token' => $ token , 'response' => $ responseBody ] ) ; } Session :: setUserInfoWithJWT ( $ dfUser ) ; $ response = Session :: getPublicInfo ( ) ; $ response [ 'oauth_token' ] = $ token ; if ( isset ( $ responseBody [ 'id_token' ] ) ) { $ response [ 'id_token' ] = $ responseBody [ 'id_token' ] ; } return $ response ; }
Logs in OAuth user

@param \Laravel\Socialite\Contracts\User $user

@return array
Logs in OAuth user