-
-
Save parzibyte/c76d14329b94eb02bee7474cf1a7e8ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\Auth; | |
use Illuminate\Support\Facades\Log; | |
use Illuminate\Support\Facades\Session; | |
use Illuminate\Support\Facades\URL; | |
class CheckForCustomerLoggedIn | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
Session::put('url.intended', URL::full()); | |
if (!Auth::check()) { | |
Log::debug("No hay usuario logueado"); | |
return redirect()->route("authenticate_customer"); | |
} | |
if (!Auth::user()->customer) { | |
Log::debug("El usuario no es un cliente"); | |
return redirect()->route("authenticate_customer"); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment