Working on app structure.
This commit is contained in:
28
app/http/filters/AuthFilter.php
Normal file
28
app/http/filters/AuthFilter.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AuthFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter(Request $request)
|
||||
{
|
||||
if (Auth::guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
return Response::make('Unauthorized', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect::guest('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
app/http/filters/BasicAuthFilter.php
Normal file
15
app/http/filters/BasicAuthFilter.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class BasicAuthFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
return Auth::basic();
|
||||
}
|
||||
|
||||
}
|
||||
21
app/http/filters/CsrfFilter.php
Normal file
21
app/http/filters/CsrfFilter.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
|
||||
class CsrfFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter(Route $route, Request $request)
|
||||
{
|
||||
if (Session::token() != $request->input('_token'))
|
||||
{
|
||||
throw new Illuminate\Session\TokenMismatchException;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
app/http/filters/GuestFilter.php
Normal file
18
app/http/filters/GuestFilter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class GuestFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
if (Auth::check())
|
||||
{
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
app/http/filters/MaintenanceFilter.php
Normal file
18
app/http/filters/MaintenanceFilter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class MaintenanceFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
if (App::isDownForMaintenance())
|
||||
{
|
||||
return Response::make('Be right back!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user