diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php new file mode 100644 index 0000000..e40500b --- /dev/null +++ b/app/controllers/AdminController.php @@ -0,0 +1,65 @@ +beforeFilter('auth'); + } + + public function home() + { + return View::make('login'); + } + + public function manageUsers() + { + + } + + public function viewUser($id) + { + + } + + public function destroyUser($id) + { + + } + + public function restoreUser($id) + { + + } + + public function viewStats() + { + + } + + public function showContact($id) + { + + } + + public function contactUser($id) + { + + } + + public function revokeAccess($id) + { + + } + + public function showMatches() + { + + } + + +} \ No newline at end of file diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index a04fb06..c851044 100755 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -15,8 +15,13 @@ class HomeController extends BaseController { | */ - public function showWelcome() + public function index() { + if(Auth::check()) + { + return Redirect::route('user', Auth::id()); + } + return View::make('home'); } diff --git a/app/controllers/SessionController.php b/app/controllers/SessionController.php index d85b5d6..d17acb4 100644 --- a/app/controllers/SessionController.php +++ b/app/controllers/SessionController.php @@ -5,16 +5,14 @@ class SessionController extends \BaseController public function showLogin() { + if(Auth::check()) + { + return Redirect::route('user', Auth::id()); + } + return View::make('login'); } - public function doLogout() - { - Auth::logout(); - return Redirect::to('login'); - Session::forget('user'); - } - public function doLogin() { $rules = array( @@ -68,4 +66,11 @@ class SessionController extends \BaseController } + public function doLogout() + { + Auth::logout(); + return Redirect::to('login'); + Session::forget('user'); + } + } \ No newline at end of file diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index a17a2d9..cc8477d 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -4,7 +4,6 @@ class UserController extends \BaseController { - public function index() { $users = User::all(); @@ -39,6 +38,7 @@ class UserController extends \BaseController array('first' => Input::get('first'), 'last' => Input::get('last'), 'email' => Input::get('email'), + 'level' => 'user', 'password' => Hash::make(\Input::get('password')))); if($user->save()) @@ -182,7 +182,7 @@ class UserController extends \BaseController if ($user->save()) { - return Redirect::route('users', array($user_id)); + return Redirect::route('user', array($user_id)); }else { \Redirect::back('complete', array($user_id, $group_id )); @@ -223,7 +223,7 @@ class UserController extends \BaseController $user = User::find($id); \Session::flash('message', 'You have successfully updated your profile.'); - return Redirect::to('users', array($id)); + return Redirect::to('user', array($id)); } } diff --git a/app/database/migrations/2014_06_29_233811_alter_user_table_add_admin_column.php b/app/database/migrations/2014_06_29_233811_alter_user_table_add_admin_column.php new file mode 100644 index 0000000..839edf1 --- /dev/null +++ b/app/database/migrations/2014_06_29_233811_alter_user_table_add_admin_column.php @@ -0,0 +1,34 @@ +string('level', 32)->after('remember_token'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function(Blueprint $table) + { + $table->dropColumn('level'); + }); + } + +} diff --git a/app/filters.php b/app/filters.php index 2a780f7..c6ffda4 100755 --- a/app/filters.php +++ b/app/filters.php @@ -78,3 +78,15 @@ Route::filter('csrf', function() throw new Illuminate\Session\TokenMismatchException; } }); + +Route::filter('admin', function() +{ + if(Auth::check() && Auth::user()->level != 'admin') + { + \Session::flash('message', 'You tried to access restricted area!'); + return Redirect::to('denied'); + } +}); + +Route::when('admin/*', 'admin'); + diff --git a/app/models/User.php b/app/models/User.php index 5b80b15..f5c99d3 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -14,7 +14,7 @@ class User extends Eloquent implements UserInterface, RemindableInterface { protected $table = 'users'; protected $fillable = array( - 'first', 'last', 'email', 'password', 'location', 'skills', 'photo', 'bio', 'remember_token'); + 'first', 'last', 'email', 'password', 'location', 'skills', 'photo', 'bio', 'remember_token', 'level'); /** * The attributes excluded from the model's JSON form. @@ -67,4 +67,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface { { return 'remember_token'; } + + public function getFullName() + { + return $this->first. ' ' . $this->last; + } } diff --git a/app/routes.php b/app/routes.php index 361cfee..84c15ae 100755 --- a/app/routes.php +++ b/app/routes.php @@ -14,7 +14,7 @@ /** * User Session Controller routes */ -Route::get('/', function(){return View::make('home') ;}); +Route::get('/', array('as' => 'home', 'uses' => 'HomeController@index')); Route::get('login', array('as' => 'login', 'uses' => 'SessionController@showLogin')); Route::post('login', array('uses' => 'SessionController@doLogin')); @@ -30,7 +30,7 @@ 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('users/{id}', array('as' => 'users', 'uses' => 'UserController@showProfile')); + Route::get('user/{id}', array('as' => 'user', 'uses' => 'UserController@showProfile')); 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')); @@ -46,4 +46,26 @@ Route::post('password/remind', array('uses' => 'RemindersController@postRemind') Route::get('password/reset/{token}', array('uses' => 'RemindersController@getReset')); Route::post('password/reset', array('uses' => 'RemindersController@postReset')); +/** + * Admin Routes ++ Management Stuff out of reach for regular users + */ +Route::group(array('before' => 'auth|admin'), function() +{ + Route::get('admin', array('as' => 'admin', 'uses' => 'AdminController@home')); + Route::get('admin/users', array('as' => 'all', 'uses' => 'AdminController@manageUsers')); + Route::get('admin/user/{id}', array('as' => 'userx', 'uses' => 'AdminController@viewUser')); + Route::delete('admin/user/{id}', array('uses' => 'AdminController@destroyUser')); + Route::post('admin/user/restore/{id}', array('uses' => 'AdminController@restoreUser')); + Route::get('admin/user/stats', array('as' => 'stats', 'uses' => 'AdminController@viewStats')); + Route::get('admin/user/contact/{id}', array('as' => 'contact', 'uses' => 'AdminController@showContact')); + Route::post('admin/user/contact', array('uses' => 'AdminController@contactUser')); + Route::post('admin/user/revoke', array('uses' => 'AdminController@revokeAccess')); + Route::get('admin/users/matches', array('as' => 'matches', 'uses' => 'AdminController@showMatches')); + +}); + +Route::get('denied', function() +{ + return View::make('404'); +}); diff --git a/app/views/404.blade.php b/app/views/404.blade.php new file mode 100644 index 0000000..428ae6d --- /dev/null +++ b/app/views/404.blade.php @@ -0,0 +1,74 @@ + + + + 403 Forbidden - Mentconnect + {{HTML::style('css/mentconnect.css')}} + {{HTML::style('css/denied.css') }} + + + +
+ +
+ +
+
+
+
+

Access Denied Error 403

+
+

Apparently you tried accessing a restricted area and the gods were not very pleased. Please press the Back button to navigate back to where you were,

+

Or you could just press this neat little button:

+ Take Me Home +
+
+
+
+
+ + + + + + diff --git a/app/views/login.blade.php b/app/views/login.blade.php index 49b1c1d..26f4d04 100644 --- a/app/views/login.blade.php +++ b/app/views/login.blade.php @@ -4,6 +4,7 @@ Mentconnect - Login {{HTML::style('css/mentconnect.css')}} +
diff --git a/app/views/users/choice.blade.php b/app/views/users/choice.blade.php index 63ab3b7..69d507f 100644 --- a/app/views/users/choice.blade.php +++ b/app/views/users/choice.blade.php @@ -4,6 +4,7 @@ Mentconnect Inc - Profile + {{HTML::style('css/mentconnect.css')}} diff --git a/app/views/users/complete.blade.php b/app/views/users/complete.blade.php index a0dfc43..fb86426 100644 --- a/app/views/users/complete.blade.php +++ b/app/views/users/complete.blade.php @@ -4,6 +4,7 @@ Mentconnect Inc + {{HTML::style('css/mentconnect.css')}} diff --git a/app/views/users/create.blade.php b/app/views/users/create.blade.php index 7c3be0b..f163113 100644 --- a/app/views/users/create.blade.php +++ b/app/views/users/create.blade.php @@ -4,6 +4,7 @@ Mentconnect Inc + {{HTML::style('css/mentconnect.css')}} diff --git a/app/views/users/group.blade.php b/app/views/users/group.blade.php index 836caba..6f9d956 100644 --- a/app/views/users/group.blade.php +++ b/app/views/users/group.blade.php @@ -4,6 +4,7 @@ Mentconnect Inc - Profile + {{HTML::style('css/mentconnect.css')}} diff --git a/app/views/users/index.blade.php b/app/views/users/index.blade.php index 5ded706..eed48a4 100644 --- a/app/views/users/index.blade.php +++ b/app/views/users/index.blade.php @@ -4,7 +4,9 @@ Users - mentconnect inc + {{HTML::style('css/mentconnect.css')}} + {{HTML::style('css/denied.css')}}
@@ -74,26 +76,28 @@


- diff --git a/app/views/users/mentees.blade.php b/app/views/users/mentees.blade.php index 4817a5e..20f6901 100644 --- a/app/views/users/mentees.blade.php +++ b/app/views/users/mentees.blade.php @@ -4,7 +4,9 @@ Users - mentconnect inc + {{HTML::style('css/mentconnect.css')}} + {{HTML::style('css/denied.css')}}
@@ -74,26 +76,28 @@


- diff --git a/app/views/users/mentors.blade.php b/app/views/users/mentors.blade.php index a6e6a28..8b49e11 100644 --- a/app/views/users/mentors.blade.php +++ b/app/views/users/mentors.blade.php @@ -4,7 +4,9 @@ Users - mentconnect inc + {{HTML::style('css/mentconnect.css')}} + {{HTML::style('css/denied.css')}}
@@ -71,29 +73,29 @@ -
-

- - diff --git a/app/views/users/profile.blade.php b/app/views/users/profile.blade.php index 0501887..22cc84e 100644 --- a/app/views/users/profile.blade.php +++ b/app/views/users/profile.blade.php @@ -8,6 +8,7 @@ {{HTML::style('css/userprofile.css')}} + @@ -50,10 +51,10 @@
@@ -82,7 +83,7 @@
Hi Check this new Bootstrap plugin
12:10 PM
-
This is the message body1
+
This is the message body

diff --git a/composer.json b/composer.json index bb5662a..a312d7a 100755 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "keywords": ["framework", "laravel"], "license": "MIT", "require": { - "laravel/framework": "4.1.*" + "laravel/framework": "4.1.*", + "zizaco/entrust": "dev-master" }, "autoload": { "classmap": [ diff --git a/public/css/denied.css b/public/css/denied.css new file mode 100644 index 0000000..eee4256 --- /dev/null +++ b/public/css/denied.css @@ -0,0 +1,18 @@ +.center {text-align: center; margin-left: auto; margin-right: auto; margin-bottom: auto; margin-top: auto;} + + +#container { + min-height:100%; + position:relative; +} + +#body { + padding:10px; + padding-bottom:40px; +} +#footer { + position:absolute; + bottom:0; + width:100%; + height:60px; +} \ No newline at end of file diff --git a/public/css/mentconnect.css b/public/css/mentconnect.css index d2e9cda..0d25f77 100755 --- a/public/css/mentconnect.css +++ b/public/css/mentconnect.css @@ -4859,7 +4859,7 @@ header { margin-bottom: 60px; } #footer { - background-color: #444444; + background-color: #fff; padding: 70px 0px 35px 0px; color: #FFF; line-height: 30px; } diff --git a/public/images/users/profile_53b0a649df6d2.JPG b/public/images/users/profile_53b0a649df6d2.JPG new file mode 100644 index 0000000..52af230 Binary files /dev/null and b/public/images/users/profile_53b0a649df6d2.JPG differ diff --git a/public/images/users/profile_53b0a706683b8.JPG b/public/images/users/profile_53b0a706683b8.JPG new file mode 100644 index 0000000..ae3569e Binary files /dev/null and b/public/images/users/profile_53b0a706683b8.JPG differ diff --git a/public/images/users/profile_53b0d7496e11b.png b/public/images/users/profile_53b0d7496e11b.png new file mode 100644 index 0000000..8a586a8 Binary files /dev/null and b/public/images/users/profile_53b0d7496e11b.png differ diff --git a/vendor/autoload.php b/vendor/autoload.php index a0296ed..2cf8853 100755 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a::getLoader(); +return ComposerAutoloaderInit6d2e6d08a33bae4469244f4d9572f9d4::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index a884f0a..2cc8a73 100755 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'AlterUserTableAddAdminColumn' => $baseDir . '/app/database/migrations/2014_06_29_233811_alter_user_table_add_admin_column.php', 'AlterUserTableAddColumns' => $baseDir . '/app/database/migrations/2014_06_28_024032_alter_user_table_add_columns.php', 'AlterUserTableReplaceColumn' => $baseDir . '/app/database/migrations/2014_06_29_015251_alter_user_table_replace_column.php', 'BaseController' => $baseDir . '/app/controllers/BaseController.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 75b6ed8..51d37bf 100755 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a +class ComposerAutoloaderInit6d2e6d08a33bae4469244f4d9572f9d4 { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit6d2e6d08a33bae4469244f4d9572f9d4', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit6d2e6d08a33bae4469244f4d9572f9d4', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); @@ -49,14 +49,14 @@ class ComposerAutoloaderInit388bc9429cea0a8e4d09dc1c56592c4a $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequire388bc9429cea0a8e4d09dc1c56592c4a($file); + composerRequire6d2e6d08a33bae4469244f4d9572f9d4($file); } return $loader; } } -function composerRequire388bc9429cea0a8e4d09dc1c56592c4a($file) +function composerRequire6d2e6d08a33bae4469244f4d9572f9d4($file) { require $file; }