Created
January 14, 2016 08:27
-
-
Save lagbox/a255adb494d7c044e05a to your computer and use it in GitHub Desktop.
Auth Middleware from filter
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 Lang; | |
use Closure; | |
class AuthCheck | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if ($request->is('panel*')) { | |
config()->set('auth.model', 'Serverfireteam\Panel\Admin'); | |
} | |
if (is_null($request->user())) { | |
$message = session('message', Lang::get('panel::fields.enterEmail')); | |
return redirect('/panel/login') | |
->with('message', $message) | |
->with('mesType', 'message'); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you need a single 'auth' middleware that can be used for the front side and the panel backside?
And if that is the case, where do you want the users who are not authenticated redirected to on the front?