dimanche 30 juillet 2017

Laravel 5.4 - Site-wide authentication checking

I'm looking to find the best way to implement site-wide authentication checking in Laravel 5.4

I'm building a website that has a growing number of pages that check for rows in a database assigned to a user. If someone visits a page on the site that carries out this function, and they are not logged in, Laravel will give

"Trying to get property of non-object"

and display its error page.

I need to remove all Laravel error pages from my project, to clean it up, and I'm starting with these errors:

Current solution:

My current solution is that wherever a route makes these checks in a controller, I wrap it in

if (Auth::check()) {

I'm wondering if there is a better solution other than wrapping all such code in this?

Edit I need to go and learn how middleware works.



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

Aucun commentaire:

Enregistrer un commentaire