EscolaLMS/API

View on GitHub
app/Http/Middleware/ManualRoutesAuthorization.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;

class ManualRoutesAuthorization
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        if (!$request->user()) {
            if ($request->is('admin/h5p/h5p*')) {
                return Redirect::to('login');
            }
        }

        return $next($request);
    }
}