Chriz74
Chriz74

Reputation: 1480

is it safe to pass the user to view in laravel?

Is it? I mean if you get the user with $user = Auth::user(); and then send it to the view with return view ('somepage')->with('user',$user); the browser will get all user data in the view (uername, password, user_id etc..). I know you can then show what you like example {{$user->username}} but the point is, is the rest of the data somehow accessible to an 'hacker', 'script kiddie' or the likes?

Upvotes: 2

Views: 78

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163898

Auth::user() is accesible from all views anyway.

Browser will not get all info like password, user_id etc. Browser gets only HTML generated by Blade template engine and it contains only things you want to share.

For example, you'll do {{ Auth::user()->username }}, browser will get username, but nothing else.

Upvotes: 1

Related Questions