Ejemplo n.º 1
0
 /**
  * Handle an incoming request. User must be logged in to do admin check
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->is_admin == 1) {
         return $next($request);
     }
     return redirect()->guest('/');
 }
Ejemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->connections()->where('connection_id', '=', $request->segment(3))->count() == 0) {
         return $next($request);
     }
     return redirect()->back()->withErrors(['Already Connected', 'You can not connect with this person cause the connection already exists.']);
 }
Ejemplo n.º 3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (\Auth::user()->can($role . '-access')) {
         return $next($request);
     }
     return response('Unauthorized.', 401);
 }
Ejemplo n.º 4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->salesman_yn == 'Y') {
         return $next($request);
     }
     return redirect('/');
 }
Ejemplo n.º 5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->nivelAccess == 1) {
         return redirect('/mbl');
     }
     return $next($request);
 }
Ejemplo n.º 6
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = \Route::getCurrentRoute();
     // $route->uri(), $request->path()
     $roles = \Auth::user()->roles;
     $allow = true;
     try {
         // Check if route has permission
         foreach ($roles as $role) {
             foreach ($role->permissions as $permission) {
                 $allow = $allow & !$this->denied($request, $route, $permission);
             }
         }
     } catch (\Exception $e) {
         \Log::error($e->getFile() . ':' . $e->getLine() . ' ' . $e->getMessage());
         $allow = false;
     }
     // Apply access
     \Log::info('ACCESS:' . \Auth::user()->name . ':' . $request->method() . ':' . $request->path() . ':' . ($allow ? 'ALLOWED' : 'DENIED'));
     if (!$allow) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return response(view('admin/unauthorized'), 401);
         }
     } else {
         return $next($request);
     }
 }
Ejemplo n.º 7
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->isSudo()) {
         return $next($request);
     }
     return redirect('/');
 }
Ejemplo n.º 8
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->role != 'admin') {
         return "This page for only ADMIN!";
     }
     return $next($request);
 }
Ejemplo n.º 9
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $siteID = $request->route('sites');
     $site = \App\Models\Site::find($siteID);
     // normal and admin users accessing other site info
     if (\Auth::user()->super == "No") {
         if (\Auth::user()->site_id != $siteID) {
             if ($request->ajax()) {
                 return response('Unauthorized', 401);
             } else {
                 return redirect()->guest('noAccess');
             }
         }
     }
     // if super user is trying to access a site belonging to another company
     if (\Auth::user()->super == "Yes") {
         if (\Auth::user()->site->company_id != $site->company_id) {
             if ($request->ajax()) {
                 return response('Unauthorized', 401);
             } else {
                 return redirect()->guest('noAccess');
             }
         }
     }
     return $next($request);
 }
 /**
  * filtre pour protéger les étudiants de prendre certaines routes
  * Note: pourrait probablement être remplacé par un système comme Sentry, mais ca fait la job pour l'instant. 
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->type != 'p') {
         return redirect('/home');
     }
     return $next($request);
 }
Ejemplo n.º 11
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::user()->can('can_view_dashboard')) {
         return response('Unauthorized.', 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 ($this->auth->check() && \Auth::user()->isActive()) {
         return redirect('./home');
     }
     return $next($request);
 }
Ejemplo n.º 13
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->level() < 4) {
         abort(403, "¡Usted no tiene los permisos para ingresar a este proceso.");
     }
     return $next($request);
 }
Ejemplo n.º 14
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->team_id) {
         return redirect()->action('TeamsController@show');
     }
     return $next($request);
 }
Ejemplo n.º 15
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $roleName)
 {
     if (Auth::check() && !Auth::user()->hasRole($roleName)) {
         return abort(401, 'Unauthorized');
     }
     return $next($request);
 }
Ejemplo n.º 16
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             //                return redirect()->guest('auth/login');
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('giangvien/*')) {
         if (\Auth::user()->quyen != 'gv') {
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('quantri/*')) {
         if (\Auth::user()->quyen != 'qt') {
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('sinhvien/*')) {
         if (\Auth::user()->quyen != 'sv') {
             return redirect()->guest('dangnhap');
         }
     }
     /* $action = $request->route()->getActionName();
        echo $action; */
     return $next($request);
 }
Ejemplo n.º 17
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!(\Auth::check() && \Auth::user()->isAdmin())) {
         return redirect('/')->withErrors('Access denied to ADMIN functionality!');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user() && !$request->user()->isATeamManager()) {
         return redirect("articles");
     }
     return $next($request);
 }
Ejemplo n.º 19
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->hak_akses == 1) {
         return $next($request);
     }
     return redirect(\URL::to('error'));
 }
Ejemplo n.º 20
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (!\Auth::user()->{$role}) {
         return \App::abort(401, 'You are not allowed to access this resource.');
     }
     return $next($request);
 }
Ejemplo n.º 21
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->id == \Auth::user()->id) {
         return redirect()->back();
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!in_array(\Auth::user()->user_type, config('squash.club+member'))) {
         return redirect('notifications/club-notices');
     }
     return $next($request);
 }
Ejemplo n.º 23
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!(\Auth::check() && !\Auth::user()->isBanned())) {
         return redirect('banned')->withErrors('User is banned.');
     }
     return $next($request);
 }
Ejemplo n.º 24
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri_segments = $request->segments();
     if (!empty($uri_segments) && in_array("api", $uri_segments)) {
         return $next($request);
     }
     if (\Auth::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('http://login.' . \Config::get('app.domain') . '/');
         }
     }
     $usuario = \Auth::user();
     if (!empty($usuario)) {
         //Menú de administrador
         if ($usuario->hasRole('administrador')) {
             \Menu::make('menu_lateral', function ($menu) {
                 $menu->add('Inicio', 'inicio');
             });
         }
     } else {
         \Redirect::to('/error500');
     }
     return $next($request);
 }
Ejemplo n.º 25
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request Request Object
  * @param \Closure                 $next    Closure Object
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\Auth::user()->hasRole('admin')) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
Ejemplo n.º 26
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->ref_user_level_id != 3) {
         return response('akses ditolak', 401);
     }
     return $next($request);
 }
Ejemplo n.º 27
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->role_id != 2) {
         return redirect(\Auth::user()->role->redirect);
     }
     return $next($request);
 }
 public function handle($request, Closure $next)
 {
     if (\Auth::check() && \Auth::user()->isNotChild() && \Auth::user()->isActive()) {
         return $next($request);
     }
     return redirect('home');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!isset(\Auth::user()->is_aluno) || \Auth::user()->is_aluno != 1) {
         return redirect('/');
     }
     return $next($request);
 }
Ejemplo n.º 30
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::user()->role->name != "admin") {
         return redirect('/');
     }
     return $next($request);
 }