Retrieving and updating user info after logging in
After a user is logged in, we will need to get the information we have about him/her. In this recipe, we'll see how to get that information.
Getting ready
We will be using the code created in the Setting up and configuring the Auth library and Creating an authentication system recipes as the basis for this recipe.
How to do it...
To complete this recipe, follow these steps:
Update the profile route with this code:
Route::get('profile', function() { if (Auth::check()) { return View::make('profile')->with('user',Auth::user()); } else { return Redirect::to('login')->with('login_error','You must login first.'); } });
Create our profile view in the
app/views
directory by creating a file named asprofile.php
:<?php echo Session::get('notify') ? "<p style='color: green'>" . Session::get('notify') . "</p>" : "" ?> <h1>Welcome <?php echo $user->name ?></h1> <p>...