rydurham / L4withSentry

Laravel 4 and Sentry 2.0
300 stars 91 forks source link

"Call to a member function hasAccess() on a non-object" on some url's when not logged in #7

Closed erfanimani closed 11 years ago

erfanimani commented 11 years ago

In app/controllers/UserController.php - and a couple of other places -

if ( $currentUser->hasAccess('admin') || $currentUser->getId() == $id)

should become

if ( Sentry::check() && ( $currentUser->hasAccess('admin') || $currentUser->getId() == $id))

according to http://docs.cartalyst.com/sentry-2/authentication/helpers#check-if-the-user-is-logged-in

rydurham commented 11 years ago

The Sentry::check() call is there, it is just usually a line or two before the hasAccess() call.