diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index c851044..6384ff3 100755 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -19,7 +19,7 @@ class HomeController extends BaseController { { if(Auth::check()) { - return Redirect::route('user', Auth::id()); + return Redirect::route('user'); } return View::make('home'); diff --git a/app/controllers/SessionController.php b/app/controllers/SessionController.php index d17acb4..68e4e3e 100644 --- a/app/controllers/SessionController.php +++ b/app/controllers/SessionController.php @@ -7,7 +7,7 @@ class SessionController extends \BaseController { if(Auth::check()) { - return Redirect::route('user', Auth::id()); + return Redirect::route('user'); } return View::make('login'); @@ -69,7 +69,9 @@ class SessionController extends \BaseController public function doLogout() { Auth::logout(); + return Redirect::to('login'); + Session::forget('user'); } diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index cc8477d..066d178 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -29,7 +29,7 @@ class UserController extends \BaseController if ($validator->fails()) { - return Redirect::to('users/create') + return Redirect::route('create') ->withErrors($validator) ->withInput(Input::except('password')); } else @@ -49,7 +49,7 @@ class UserController extends \BaseController }else { - return \Redirect::to('create')->with('errors', 'Something terrible happened'); + return \Redirect::route('create')->with('errors', 'Something terrible happened'); } } @@ -182,7 +182,7 @@ class UserController extends \BaseController if ($user->save()) { - return Redirect::route('user', array($user_id)); + return Redirect::route('user'); }else { \Redirect::back('complete', array($user_id, $group_id )); @@ -190,8 +190,16 @@ class UserController extends \BaseController } - public function showProfile($id) + public function showProfile() { + $user = Auth::user(); + + return View::make('users.profile')->with('user', $user); + } + + public function showUser($id) + { + $user = User::find($id); return View::make('users.profile')->with('user', $user); @@ -205,6 +213,7 @@ class UserController extends \BaseController }else { $user = User::find($id); + $group = UserXrefRole::where('user_id', '=', $id)->get(); $group_id = (int)$group[0]->role_id; @@ -222,8 +231,10 @@ class UserController extends \BaseController { $user = User::find($id); + //update the user here + \Session::flash('message', 'You have successfully updated your profile.'); - return Redirect::to('user', array($id)); + return Redirect::route('user'); } } diff --git a/app/filters.php b/app/filters.php index c6ffda4..e75a06c 100755 --- a/app/filters.php +++ b/app/filters.php @@ -83,7 +83,7 @@ Route::filter('admin', function() { if(Auth::check() && Auth::user()->level != 'admin') { - \Session::flash('message', 'You tried to access restricted area!'); + \Session::flash('message', 'You tried to access a restricted area!'); return Redirect::to('denied'); } }); diff --git a/app/routes.php b/app/routes.php index 84c15ae..73a0d1b 100755 --- a/app/routes.php +++ b/app/routes.php @@ -30,7 +30,8 @@ Route::group(array('before' => 'auth'), function() Route::get('users/group/{user_id}', array('as' => 'group', 'uses' => 'UserController@chooseGroup')); Route::get('users/group/{user_id}/{group_id}', array('as' => 'complete', 'uses' => 'UserController@completeRegistration')); Route::post('users/group/complete', array('uses' => 'UserController@saveProfile')); - Route::get('user/{id}', array('as' => 'user', 'uses' => 'UserController@showProfile')); + Route::get('user/profile', array('as' => 'user', 'uses' => 'UserController@showProfile')); + Route::get('user/{id}', array('as' => 'usr', 'uses' => 'UserController@showUser')); Route::get('users/{id}/edit', array('as' => 'edit', 'uses' => 'UserController@edit')); Route::put('users/{id}/update', array('uses' => 'UserController@update')); Route::get('users', array('as' => 'users', 'uses' => 'UserController@index')); diff --git a/app/views/users/index.blade.php b/app/views/users/index.blade.php index eed48a4..7d93fc7 100644 --- a/app/views/users/index.blade.php +++ b/app/views/users/index.blade.php @@ -62,7 +62,7 @@