mardi 23 juillet 2019

Laravel cannot logout execute from curl

I've try to make curl to execute destroy session to Laravel website,I tried with Auth::logout(), auth()->logout() still didn't work

Also, i've excepting verifyCsrftoken for logout method but didn't work too

here is logout laravel source code :

public function logout(Request $request)
{
    auth()->logout();
    \Session::flush()
    $a          = Auth::user();
    $token      = $request->token;
    $logout     = AuthUser::where(['token'=>$token])->update(['is_login'=>0]);
    return 1;
}

and here is curl code

public function logout(Request $request)
    {
        //set Logout Local Session
        $this->destroy();

        //Set logout to Server 
        $client = new Client([
            'base_uri' => $this->url,
        ]);

        $path = '/auth/logout';

        $response = $client->request('POST', $path, [
            'form_params' => [
                'token' => \Session::get('token'),
            ],
            'exceptions' => false
        ]);
        $return = json_decode($response->getBody()->getContents());
        dd($return);
        if ($return == 1) 
        {
            return redirect('login');
        }
    }

Anyone can help me out ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire