Пример #1
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->credentials->check()) {
         $this->logger->info('User tried to access a page without being logged in', ['path' => $request->path()]);
         if ($request->ajax()) {
             throw new UnauthorizedHttpException('Action Requires Login');
         }
         return Redirect::guest(URL::route('account.login'))->with('error', 'You must be logged in to perform that action.');
     }
     if (!$this->credentials->hasAccess($level = $this->level())) {
         $this->logger->warning('User tried to access a page without permission', ['path' => $request->path(), 'permission' => $level]);
         throw new AccessDeniedHttpException(ucfirst($level) . ' Permissions Are Required');
     }
     return $next($request);
 }
Пример #2
0
 /**
  * Handle a navigation.bar event third.
  *
  * @return void
  */
 public function onNavigationBarThird()
 {
     if ($this->credentials->check()) {
         // add the view users link
         if ($this->credentials->hasAccess('mod')) {
             $this->navigation->addToBar(['title' => 'View Users', 'slug' => 'users', 'icon' => 'user']);
         }
         // add the create user link
         if ($this->credentials->hasAccess('admin')) {
             $this->navigation->addToBar(['title' => 'Create User', 'slug' => 'users/create', 'icon' => 'star']);
         }
         // add the create page link
         if ($this->credentials->hasAccess('edit')) {
             $this->navigation->addToBar(['title' => 'Create Page', 'slug' => 'pages/create', 'icon' => 'pencil']);
         }
         // add the create post link
         if ($this->blogging) {
             if ($this->credentials->hasAccess('blog')) {
                 $this->navigation->addToBar(['title' => 'Create Post', 'slug' => 'blog/posts/create', 'icon' => 'book']);
             }
         }
         // add the create event link
         if ($this->events) {
             if ($this->credentials->hasAccess('edit')) {
                 $this->navigation->addToBar(['title' => 'Create Event', 'slug' => 'events/create', 'icon' => 'calendar']);
             }
         }
     }
 }
Пример #3
0
 /**
  * Handle a navigation.bar event third.
  *
  * @return void
  */
 public function onNavigationBarThird()
 {
     if ($this->credentials->check()) {
         // add the view users link
         if ($this->credentials->hasAccess('mod')) {
             $this->navigation->addToBar(['title' => trans('navigation.users'), 'slug' => 'users', 'icon' => 'user']);
         }
         // add the create user link
         if ($this->credentials->hasAccess('admin')) {
             $this->navigation->addToBar(['title' => trans('navigation.new_user'), 'slug' => 'users/create', 'icon' => 'star']);
         }
         // add the create page link
         if ($this->credentials->hasAccess('edit')) {
             $this->navigation->addToBar(['title' => trans('navigation.new_page'), 'slug' => 'pages/create', 'icon' => 'pencil']);
         }
         // add the create post link
         if (Config::get('cms.blogging')) {
             if ($this->credentials->hasAccess('blog')) {
                 $this->navigation->addToBar(['title' => trans('navigation.new_post'), 'slug' => 'content/posts/create', 'icon' => 'book']);
             }
         }
         // add the create event link
         if (Config::get('cms.events')) {
             if ($this->credentials->hasAccess('edit')) {
                 $this->navigation->addToBar(['title' => trans('navigation.new_event'), 'slug' => 'events/create', 'icon' => 'calendar']);
             }
         }
     }
 }
Пример #4
0
 /**
  * Create a navigation bar.
  *
  * @param string $type
  *
  * @return string
  */
 public function make($type = 'default')
 {
     if ($this->credentials->check()) {
         if ($type === 'admin') {
             if ($this->credentials->hasAccess('admin')) {
                 // the requested type is admin, and the user is an admin
                 return $this->navigation->render('admin', 'admin', ['title' => 'Admin Panel', 'side' => $this->getSide(), 'inverse' => $this->inverse]);
             } else {
                 // the requested type is admin, and the user is NOT an admin
                 return $this->navigation->render('default', 'default', ['title' => $this->name, 'side' => $this->getSide(), 'inverse' => $this->inverse]);
             }
         } else {
             // the requested type is default, and the user is logged in
             return $this->navigation->render('default', 'default', ['title' => $this->name, 'side' => $this->getSide(), 'inverse' => $this->inverse]);
         }
     } else {
         // the requested type is default, and the user is NOT logged in
         return $this->navigation->render('default', false, ['title' => $this->name, 'inverse' => $this->inverse]);
     }
 }