1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Support\Facades\Auth;
- class Authenticate
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if (Auth::guest()) {
- if ($request->ajax()) {
- return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('auth/login');
- }
- }
- return $next($request);
- }
- }
|