Skip to content

Instantly share code, notes, and snippets.

@lagbox
Created January 14, 2016 08:27
Show Gist options
  • Save lagbox/a255adb494d7c044e05a to your computer and use it in GitHub Desktop.
Save lagbox/a255adb494d7c044e05a to your computer and use it in GitHub Desktop.
Auth Middleware from filter
<?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);
}
}
@lagbox
Copy link
Author

lagbox commented Jan 14, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment