Reputation: 10886
How do I show a page only to a specific person that's signed in. For example if I've localhost/public/article/4 that's only allowed for James, how do I make sure that Harry can't see this?
Upvotes: 0
Views: 142
Reputation: 73
the correct way of do this is associate all users to a Role model. This way you could differenciate one user from others. But if you dont want this way you could use the ID of the user to validate this.
How validate this?
when you make a session in laravel you can access to the user data using
Auth::user()->id, Auth::user()->name, Auth::user()->last_login, etc...
in the controller's function the make the view you could do this (James ID's = 1)
if(Auth::user()->id == 1):
return View::make('path_to_view.show');
else:
return View::make('path_to_view.error');
endif;
Upvotes: 1