I am using jwt:auth with laravel 5.2 to authenticate in a secure manner against CSRF attacks.
You can find how to do here >> http://blog.nedex.io/create-an-api-server-for-mobile-apps-using-laravel-5-1/
I have edited the except array in VerifyCsrfToken.php middleware and added api/login and api/signup, so i can skip jwt tokens for these two actions because while i am trying to login or signup, so i still have no keys, yet.
Route::group(['prefix' => 'api'], function() {
Route::post('login', 'Api\AuthController@login');
Route::post('signup', 'Api\UsersController@signup');
Route::group(['middleware' => ['jwt.auth', 'jwt.refresh']], function() {
Route::post('logout', 'Api\AuthController@logout');
Route::get('test', function(){
return response()->json(['foo'=>'bar']);
});
Route::get('hospitals', 'Api\EmergenciesController@getHospitals');
Route::get('emergencyDetails/{id}', 'Api\EmergenciesController@getEmergencyDetails');
Route::get('profile/{id}', 'Api\UsersController@get_profile');
Route::post('submit_profile/{id}', 'Api\UsersController@submit_profile_data');
Route::post('update_property/{id}/{property}/{value}', 'Api\UsersController@update_property');
Route::post('pregnant/{id}', 'Api\UsersController@update_is_pregnant');
});
});
it works perfectly, when i send GET requests with ?token= But it gives me a TokenMismatchException when i try to send POST request although i am sending the token.
check the screenshots here >> https://www.dropbox.com/sh/a901epayh1liapd/AABCwxxBN4pSG735SxQlC2jha?dl=0
Why POST requests fail?? please help.!