Example #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);
 }
Example #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']);
             }
         }
     }
 }
Example #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']);
             }
         }
     }
 }
Example #4
0
 /**
  * Get the relevant user property for the side bar.
  *
  * @return string
  */
 protected function getSide()
 {
     $propery = $this->property;
     $user = $this->credentials->getDecoratedUser();
     return $user->{$propery};
 }
Example #5
0
 /**
  * Was the event invoked by the current user?
  *
  * @return bool
  */
 public function wasByCurrentUser()
 {
     return $this->credentials->check() && $this->credentials->getUser()->id == $this->wrappedObject->user_id;
 }
Example #6
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $this->credentials->getThrottleProvider()->enable();
     return $next($request);
 }