/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // /* |-------------------------------------------------------------------------- | Authentication Filters |-------------------------------------------------------------------------- | | The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ $router->filter('auth.basic', function () { return Auth::basic(); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ $router->filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); parent::boot($router); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { $router->filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('/'); } } }); $router->filter('auth.basic', function () { return Auth::basic(); }); $router->filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); $router->filter('admin', function () { if (Auth::check()) { if (Auth::user()->email != "*****@*****.**") { return Redirect::to('/'); } } else { return Redirect::to('/'); } }); parent::boot($router); }
/** * Define the routes for the application. * * @param \Illuminate\Routing\Router $router * @return void */ public function map(Router $router) { $router->group(['namespace' => $this->namespace], function ($router) { require app_path('Http/routes.php'); }); $router->filter("userauth", function () { if (!Auth::user()->check()) { return redirect(""); } }); $router->filter("organizationauth", function () { if (!Auth::organization()->check()) { return redirect("/organizations/login"); } }); }
/** * Define the routes for the application. * * @param \Illuminate\Routing\Router $router * @return void */ public function map(Router $router) { $router->group(['namespace' => $this->namespace], function ($router) { require app_path('Http/routes.php'); }); $router->filter('authuser', function () { if (!\Auth::check()) { return redirect()->guest('login'); } }); $router->filter('filtername', function ($route, $request, $value) { $array = explode('-', $value); // use - for delimiter return $array; // do whatever here }); }
/** * Setup the filters. * * @param \Illuminate\Routing\Router $router * @param \GrahamCampbell\Throttle\Throttle $throttle * * @return void */ protected function setupFilters(Router $router, Throttle $throttle) { $router->filter('throttle', function ($route, $request, $limit = 10, $time = 60) use($throttle) { if (!$throttle->attempt($request, $limit, $time)) { throw new TooManyRequestsHttpException($time * 60, 'Rate limit exceed.'); } }); }
public function register(Router $router, Resolver $resolver) { $reflection = new ReflectionMethodsFilter($this); foreach ($methods = $reflection->filterPrefix($this->getPrefix()) as $method) { $router->filter($method, $resolver->methodToClosure($this, $method)); } $this->registered = true; }
/** * Register the filters. * * @param Router $router * @return void */ public function registerFilters(Router $router) { foreach ($this->filters as $module => $filters) { foreach ($filters as $name => $filter) { $class = "Modules\\{$module}\\Http\\Filters\\{$filter}"; $router->filter($name, $class); } } }
/** * Define the routes for the application. * * @param \Illuminate\Routing\Router $router * @return void */ public function map(Router $router) { $router->group(['namespace' => $this->namespace], function ($router) { require app_path('Http/routes.php'); }); $router->filter('notlogin', function () { if (auth()->user()) { return redirect(athr . '/categories'); } }); }
/** * Register route filters. * * @param \Illuminate\Routing\Router $router * * @return void */ protected function registerRouteFilters(Router $router) { foreach ((array) $this->before as $before) { $router->before($before); } foreach ((array) $this->after as $after) { $router->after($after); } foreach ((array) $this->filters as $name => $filter) { $router->filter($name, $filter); } }
/** * Register a new filter with the router. * * @param string $name * @param string|callable $callback * @return void * @deprecated since version 5.1. * @static */ public static function filter($name, $callback) { \Illuminate\Routing\Router::filter($name, $callback); }