Added CORS filter. Tidied up the filters.php code
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
8
app/filters/CORSFilter.php
Normal file
8
app/filters/CORSFilter.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class CORSFilter {
|
||||
public function filter($route, $request, $response) {
|
||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user