/** * This will return a bool value based on route checking. * @param Request $request * @return boolean */ protected function excludedRoutes($request) { foreach ($this->routes as $route) { if ($request->is($route)) { return true; } } return false; }
/** * Handle an incoming request. * * @param Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { foreach ($this->openRoutes as $route) { if ($request->is($route)) { return $next($request); } } return parent::handle($request, $next); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $current = \Route::current(); $prefix = $current->getPrefix(); if ($prefix == "broadcaster/services") { if (\Request::is('broadcaster/services/news*')) { $model = "news"; } else { if (\Request::is('broadcaster/services/channel*')) { $model = "channel"; } else { if (\Request::is('broadcaster/services/vod*')) { $model = "vod"; } else { return $next($request); } } } if ($model) { if (!$this->broadcasterResource->hasService($model)) { return response(['error' => ['description' => 'No service available']], 401); } } $params = $current->parameters(); if ($params) { if ($this->broadcasterResource->canAccess($model, $params)) { return $next($request); } else { return response(['error' => ['code' => 'UNAUTHORIZED', 'description' => 'You are not authorized to access this resource.']], 401); } } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!\Request::ajax()) { return; } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!\Request::is('ws/*') && !\Request::ajax()) { return parent::handle($request, $next); } return $this->addCookieToResponse($request, $next($request)); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // dd(($request->url())); if (!$request->ajax()) { if (session()->has('visita')) { $visita = \App\visita::find(session('visita')); if ($visita->ip == \Request::ip() && count($visita) > 0) { $visita->contador = $visita->contador + 1; } else { $visita = new visita(); $visita->ip = \Request::ip(); $visita->contador = 1; } $visita->save(); } else { $visita = new visita(); $visita->ip = \Request::ip(); $visita->contador = 1; $visita->save(); $data = array('visita' => $visita->id_visita); session($data); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax()) { dd('Unauthorized'); return response('Unauthorized.', 401); } else { session_start(); if (isset($_SESSION['cart'])) { if (\Request::all()) { array_push($_SESSION['cart'], \Request::all()); } } else { $_SESSION['cart'] = []; array_push($_SESSION['cart'], \Request::all()); } if (\Auth::guest()) { \Session::flash('need_to_login_message', 'You need to log in'); } // dd($_SESSION['cart']); return redirect()->guest('login'); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // ajax() is \Request::isXmlHttpRequest() wrapper method if (!\Request::ajax()) { abort(400); } return $next($request); }
/** * @param \Request $request * @param callable $next * @return mixed * @throws DeepInException */ public function handle($request, Closure $next) { $projectId = $request->input("project_id", null); if (empty($projectId)) { throw new DeepInException("projectId不能为空~!"); } $token = $request->input("token", null); if (empty($token)) { throw new DeepInException("token不能为空~!"); } $project = Project::find($projectId); if (!$project instanceof Project) { throw new DeepInException("错误的project_id"); } $this->checkAccess($project, $request->getClientIp()); $this->checkToken($token, $project); return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { if (\Request::is('backend*')) { return redirect('/backend'); } else { return redirect('/home'); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $url = explode('/', \Request::path()); $user = \Request::session()->get('user'); $cia = \Request::session()->get('company'); if ($url[0] != 'dashboard' && $url[1] == $cia['slug'] && \Auth::user()->active == true) { return $next($request); } else { return abort('404'); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (\Auth::guest()) { } else { if (!\Request::ajax()) { $menus = \Auth::user()->generateMenu(); view()->share(['mainMenu' => $menus]); } } view()->share(['title' => config('app.title'), 'instansi' => config('app.instansi')]); return $next($request); }
/** * Gets Medium data * @return mixed */ public static function getAnalytics() { $cacheFile = dirname(__FILE__) . "/../../../storage/analytics.js"; if (!FileCache::cached($cacheFile)) { $url = "http://www.google-analytics.com/analytics.js"; $content = Request::get($url); file_put_contents($cacheFile, $content); } else { $content = file_get_contents($cacheFile); } return response($content)->withHeaders(['Content-Type' => 'application/javascript']); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/instagram.json"; if (!FileCache::cached($cacheFile)) { $url = "https://api.instagram.com/v1/users/" . $_ENV['INSTAGRAM_USER_ID'] . "/media/recent/?access_token=" . $_ENV['INSTAGRAM_ACCESS_TOKEN'] . "&count=3"; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/medium.json"; if (!FileCache::cached($cacheFile)) { $url = 'https://medium.com/@peugenio/latest?format=json'; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/github.json"; if (!FileCache::cached($cacheFile)) { $url = "https://api.github.com/users/voxmachina/repos?sort=updated&per_page=3"; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = \Auth::user(); if ($user->role_id != 1) { $controller = \Request::segment(2); if (!empty($controller)) { $cek = Role::find($user->role_id); if (empty($cek->menus()->whereSlug($controller)->first()->id)) { return redirect('auth/authorized'); } } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { $currentRouteAction = \Route::currentRouteAction(); $c_a = explode('@', $currentRouteAction); if (count($c_a) < 2) { return $next($request); } list($controller, $action) = explode('@', $currentRouteAction); $cname = substr($controller, strlen('App\\Http\\Controllers\\')); $user = Auth::User(); if (!$user) { $user_count = User::count(); if ($user_count == 0) { if ($cname == 'Auth\\AuthController' && ($action == 'showRegistrationForm' || $action == 'register')) { return $next($request); } else { return redirect()->action('Auth\\AuthController@showRegistrationForm')->with('message', 'You must create the 1st user(which would be super admin) before any tasks!')->with('message_type', 'warning'); } } else { if ($cname == 'Auth\\AuthController') { if ($action == 'showRegistrationForm' || $action == 'register') { return redirect()->action('Auth\\AuthController@showLoginForm')->with('message', 'Only super admin can create more users!')->with('message_type', 'warning'); } else { if ($action == 'showLoginForm' || $action == 'login') { return $next($request); } } } else { if ($cname == 'Auth\\PasswordController') { return $next($request); } } } return redirect(action('Auth\\AuthController@showLoginForm') . '?continue=' . \Request::url())->with('message', 'You must login to visit this page!')->with('message_type', 'warning'); } else { if ($user->type === 0) { return $next($request); } //Super Admin! if ($cname == 'PageController' || $cname == 'Auth\\AuthController' && $action == 'logout' || $cname == 'HomeController' && ($action == 'getIndex' || $action == 'getHome')) { return $next($request); } } return redirect('/'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { \Me::setOnline(); if (\Auth::check()) { $access = \Menu::access()['return']; if ($access == false) { return redirect('/'); } if (!empty(\Session::get('lock')) && \Request::path() != 'lockscreen') { return redirect('/lockscreen'); } } if (\Auth::guest()) { if (!empty(\Session::get('lock'))) { \Session::forget('lock'); } } return $next($request); }
public function handle($request, Closure $next, $guard = null) { \App::setLocale(config('gtcmslang.defaultAdminLocale')); $showLoginMessage = true; if (config('gtcms.adminAutoLogin') && \Auth::guest()) { $user = User::where('role', 'admin')->first(); \Auth::login($user); $showLoginMessage = false; } $allowedUserRoles = config('gtcms.allowedUserRoles'); if (\Auth::guest() || !in_array(\Auth::user()->role, $allowedUserRoles)) { if (\Route::current()->uri() != "admin/login") { if (\Request::ajax() && \Request::get('getIgnore_isAjax')) { $data = array('success' => false, 'message' => "Session timeout", 'redirectToLogin' => true); return \Response::json($data); } else { return \Redirect::to('/admin/login'); } } } else { if (\Route::current()->uri() == "admin/login") { if ($showLoginMessage) { MessageManager::setError(trans('gtcms.alreadyLoggedIn')); } return \Redirect::to("/admin"); } } if (\Session::get('accessDenied')) { if (\Route::currentRouteName() != "restricted") { \Session::put('accessDenied', true); return \Redirect::to('/access-denied'); } } else { if (\Route::currentRouteName() == "restricted") { MessageManager::setError(trans('gtcms.accessGranted')); \Session::put('accessDenied', false); return \Redirect::to("/admin"); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $url = explode('/', \Request::path()); $user = \Request::session()->get('user'); $cia = \Request::session()->get('company'); if ($cia['slug'] == 'onsingle' && $url[0] != 'company') { $profile = User::find(\Auth::user()->id)->profile; if ($profile) { $request->session()->put('profile.first_name', $profile->first_name); $request->session()->put('profile.laste_name', $profile->last_name); $request->session()->put('profile.full_name', $profile->first_name . ' ' . $profile->last_name); $request->session()->put('profile.office', $profile->office); } else { $request->session()->put('profile.first_name', \Auth::user()->email); $request->session()->put('profile.laste_name', ''); $request->session()->put('profile.full_name', 'Please update your profile'); $request->session()->put('profile.office', 'Undefined'); } return $next($request); } return abort('404'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $this->menus = \Request::segment(1) == 'admin' ? Menu::roots() : Menu::roots()->active(); view()->share('menus', $this->menus); return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, \Closure $next) { \Log::info('処理終了。', ['Ip' => \Request::server('REMOTE_ADDR'), 'SessionId' => \Session::getId(), 'url' => \Request::url(), 'method' => \Request::method()]); return $next($request); }