Route without token protection requesting token

0

I am trying to register a new user who is not on the middleware protected route token jwt, but I am getting the return.

{
    "error": "The token could not be parsed from the request"
}

Following routes routes / api.php

Route::group(['middleware' => 'jwt.auth'], function(){
    Route::resource('tipoDespesa', 'TipoDespesaController');
    Route::resource('mudarTexto', 'MudarTextoController');

    // Usuario
    // Route::get('user', 'PessoaController@show');
    // Route::put('user', 'PessoaController@update');
    // Route::delete('user', 'PessoaController@destroy');

    Route::resource('conta', 'ContaController');
    Route::resource('categoria-despesa', 'CategoriaDespesaController');
    Route::put('conta/ativar/{id}', 'ContaController@ativar');
    Route::get('auth/me', 'AuthController@me');
});

Route::post('auth/login', 'AuthController@login');
Route::post('auth/logout', 'AuthController@logout');
Route::post('auth/refresh', 'AuthController@refresh');
Route::post('new/user', 'PessoaController@store');

Postman

PersonController@store

    
asked by anonymous 12.11.2018 / 16:02

1 answer

0

Herick,

I saw that the route that is calling in Postman is

Route :: post ('new / user', 'PersonController @ store');

And as you use the POST method Laravel by definition requires a token to avoid Cross Site Request Forgery, see the link documentation below that inside an HTML form we used {{csrf_field ()}} to create a "hidden "with this token automatically generated by PHP (Server side).

Documentation: link

The error that is appearing for you has no reference with JWT, but with the POST verb, you can change to GET and pass all the data through the URL but that is not a good idea. The principle is that if you are going to create a new user you must already be logged in or already be in the application, if you want to do through an API to consume a service you will have to authenticate first

I hope it did not get too confusing, but read the documentation or give me a ring around here and we'll help.

Abc

    
12.11.2018 / 20:18