samedi 28 novembre 2015

Laravel 5 : Client error 400 after user click cancel authorize the facebook permission

i'm currently facing some issue regarding facebook login. I've integrated facebook login with my application, the only problem is that the error 400 happens when user click cancel during the facebook aauthorization. Anyone have some clue for it?

Note : facebook login is working fine, problem happens when new user click sign up with facebook, but cancel the authorization.

this are the call back url from facebook. http://localhost/login/facebookCallback?error=access_denied&error_code=200&error_description=Permissions+error&error_reason=user_denied&state=gMwDR0TATB6Kt5IwIkbFCA5LOypOYSJjhK8Mz0fj#=

my route

Route::get('login/facebookLogin', 'ProfileController@redirectToProvider');
Route::get('login/facebookCallback', 'ProfileController@handleProviderCallback');
Route::get('logout/facebookLogout', 'ProfileController@facebookLogout');

my controller :

public function redirectToProvider(){
        return Socialize::with('facebook')->redirect();
    }

    public function handleProviderCallback(Request $request)
    {
        $user = Socialize::with('facebook')->user();
        $datetime = new \DateTime();
        $datetime->format('Y-m-d H:i:s');
        $datetime->getTimestamp();
        $data = User::where('facebook_id', '=', $user->getId())->first();

        if (is_null($data)) {
            $data = new User;
            $data->country_id = 1; // default to malaysia
            $data->user_name = $user->getname();
            $data->facebook_id = $user->getId();
            $data->steam_link = null;
            $data->password = null;
            $data->extra_information = null;
            $data->remember_token = null;
            $data->email = $user->getEmail();
            $data->status_id = 1;
            $data->is_verified = 1; // verified
            $data->user_type_id = 2; // normal user
            $data->account_status_id = 2; // active
            $data->created_at = $datetime;
            $data->updated_at = $datetime;
            $data->save();

            $UserLogin = User::where('facebook_id', '=', $user->getId())->first();
            Auth::login($UserLogin, true);
            return Redirect::to('profile/profileSetting')->with('data', $data);
        } else {
            $data->user_name = $user->getname();
            $data->updated_at = $datetime;
            $data->save();

            $UserLogin = User::where('facebook_id', '=', $user->getId())->first();
            Auth::login($UserLogin, true);
            return Redirect::to('/');
        }
    }

error : ClientException in Middleware.php line 69: Client error: 400



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OwMkFn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire