Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Route::controller(Controller::detect());
- Route::get('/', function()
- {
- #return View::of('layout')->nest('content', 'home.index');
- return Redirect::to('home');
- });
- Event::listen('404', function()
- {
- return Response::error('404');
- });
- Event::listen('500', function()
- {
- return Response::error('500');
- });
- Route::filter('before', function()
- {
- // Do stuff before every request to your application...
- });
- Route::filter('after', function($response)
- {
- // Do stuff after every request to your application...
- });
- Route::filter('csrf', function()
- {
- if (Request::forged()) return Response::error('500');
- });
- Route::filter('auth', function()
- {
- if (Auth::guest()) return Redirect::to('login');
- });
- Route::get('login', array('uses' => 'login@index'));
- Route::post('login', function() {
- //return "login form sent";
- //Get the person data from login
- $credentials = array(
- 'username' => Input::get('username'),
- 'password' => Input::get('password')
- );
- if(Auth::attempt($credentials)):
- //We are logged in and sending the user to home
- return Redirect::to('admin');
- else:
- //Auth fail and we are sending user back so he can log in
- return Redirect::to('login')
- ->with('login_errors', true);
- endif;
- });
- //validate_admin filter
- Route::filter('validate_admin', function ()
- {
- //get the admin check closure that should be supplied in the config
- $authCheck = Config::get('administrator.auth_check');
- if (!$authCheck())
- {
- $loginUrl = URL::to(Config::get('administrator.login_path', 'user/login'));
- $redirectKey = Config::get('administrator.login_redirect_key', 'redirect');
- $redirectUri = URL::to_route('admin_dashboard');
- return Redirect::to($loginUrl)->with($redirectKey, $redirectUri);
- }
- });
- /**
- * Admin Routes
- */
- Route::group(array('before' => 'validate_admin'), function()
- {
- Route::get('admin', array(
- 'as' => 'admin_dashboard',
- 'uses' => 'admin.dashboard@index',
- ));
- Route::any('admin/images', array(
- 'as' => 'admin_images',
- 'uses' => 'admin.images@index',
- ));
- Route::any('admin/images/id/(:any)', array(
- 'as' => 'admin_id_image',
- 'uses' => 'admin.images@id',
- )); //doesn't work
- Route::get('admin/news', array(
- 'as' => 'admin_news',
- 'uses' => 'admin.news@index',
- ));
- Route::get('admin/news/new', array(
- 'as' => 'admin_form_news',
- 'uses' => 'admin.news@new',
- ));
- });
- Route::get('logout', function() {
- Auth::logout();
- return Redirect::to('login');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement