Blade frontend with API's
Hello peepz,
I just recently joined, and have been learning Laravel for few weeks, so forgive me if my question seems bit vague.
So I have this problem.
I'm trying to use API to POST and GET stuff from blade views (so no thrid party frameworks/libraries as Vue, React or Angular).
So I have been successful doing it without any protections (tokens, passport). Now Im having hard time getting hang of making that, cause I have this mindset where I feel passport is made to get access from outside of application and I cannot figure out way if I have to use it to get access from "inside".
Btw I have set up all of passport with tables, providers etc.
If you know of some guide for dummies which could make me understand how it works better I'd appreciate.
Do you have laravels auth setup? https://laravel.com/docs/5.6/authentication
So users register and create the account and logs in. They are now authenticated.
Then you just need to put your routes that require the user to be authenticated in a middleware group. https://laravel.com/docs/5.6/middleware#middleware-groups
Route::group(['middleware' => ['auth']], function () {
// all routes that require user to be authenticated
Route::get('/some-endpoint', 'SomeController@SomeMethod');
});
Pubic routes (like homepage, etc) would be outside of that route group. Anybody trying to access a route in that group will be denied if they aren't logged in.
Please or to participate in this conversation.