Added CORS filter. Tidied up the filters.php code

This commit is contained in:
James Brooks
2014-11-25 09:48:56 +00:00
parent 00a885db98
commit a1844741bd
2 changed files with 20 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
<?php
Route::filter('no_setup', 'NoSetupFilter');
Route::filter('cors', 'CORSFilter');
/*
|--------------------------------------------------------------------------
@@ -13,24 +14,18 @@
|
*/
Route::filter('auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
Route::filter('auth', function() {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
}
else
{
} else {
return Redirect::guest('auth/login');
}
}
});
Route::filter('auth.basic', function()
{
Route::filter('auth.basic', function() {
return Auth::basic();
});
@@ -45,9 +40,10 @@
|
*/
Route::filter('guest', function()
{
if (Auth::check()) return Redirect::to('/');
Route::filter('guest', function() {
if (Auth::check()) {
return Redirect::to('/');
}
});
/*
@@ -61,10 +57,8 @@
|
*/
Route::filter('csrf', function()
{
if (Session::token() !== Input::get('_token'))
{
Route::filter('csrf', function() {
if (Session::token() !== Input::get('_token')) {
throw new Illuminate\Session\TokenMismatchException;
}
});

View File

@@ -0,0 +1,8 @@
<?php
class CORSFilter {
public function filter($route, $request, $response) {
$response->headers->set('Access-Control-Allow-Origin', '*');
return $response;
}
}