Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't modify fields in Linkedin #305

Closed
karimsamir opened this issue Dec 4, 2018 · 1 comment
Closed

I can't modify fields in Linkedin #305

karimsamir opened this issue Dec 4, 2018 · 1 comment

Comments

@karimsamir
Copy link

karimsamir commented Dec 4, 2018

This is the Code I am using

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Socialite;
use App\Models\User;

class LoginController extends Controller {

use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct() {
        $this->middleware('guest')->except('logout');
    }

    /**
     * Redirect the user to the GitHub authentication page.
     *
     * @return \Illuminate\Http\Response
     */
    public function redirectToLinkedin() {
        $fields = [
            "id", "firstName", "lastName",
            "maidenName", "headline", "specialties",
            "positions", "pictureUrl", "emailAddress"
        ];

        return Socialite::with('linkedin')
                        ->fields($fields)
                        ->redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleLinkedinCallback(Request $request) {
        $linkedinUser = Socialite::driver('linkedin')->user();

        // check if user exists in DB
        $user = User::where('linkedin', '=', $linkedinUser['id'])->first();

        // if user doesn't exit go to sign up page and populate form
        if (!$user) {

            $request->session()->put('linkedinUser', $linkedinUser->user);

            return redirect()->route('signup');
        }
//                if user exists login him/her
        Auth::loginUsingId($user->id);

        return redirect('/');
    }
}

but positions never return, I debugged the file

vendor/laravel/socialite/src/Two/LinkedInProvider.php
and var_dump
$fields
and it didn't change the default fields

@driesvints
Copy link
Member

Since we don't support that field ourselves it's best that you try asking this elsewhere:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants