Ejemplo n.º 1
0
 public function getReset($token = null)
 {
     if (is_null($token)) {
         $this->application->abort(404);
     }
     return $this->view->make('UserManagement::password.reset')->with('token', $token);
 }
Ejemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     // Check if the user is logged in
     if (!$this->auth->check()) {
         // Store the current uri in the session
         $this->session->put('url.intended', $this->request->url());
         // Redirect to the login page
         return $this->redirect->route('login');
     }
     // Check if the user has access to the dashboard page
     if (!$this->auth->hasAccess('dashboard.index')) {
         // Show the insufficient permissions page
         return $this->application->abort(403);
     }
     return $next($request);
 }
Ejemplo n.º 3
0
 /**
  * Controller function to output the CSS.
  * 
  * @param Route $route
  * @param Request $request
  * @param Response $response
  * 
  * @return Response
  */
 public function viewCss(Route $route, Request $request, Response $response)
 {
     if (!$this->isResponseObject($response)) {
         return $response;
     }
     $files = explode(',', $route->parameter('files', ''));
     if ($route->parameter('count', 0) != count($files)) {
         $this->app->abort(422, 'Length option incorrect');
     }
 }
Ejemplo n.º 4
0
 /**
  * Filters a route for role(s) and/or permission(s).
  *
  * If the third parameter is null then abort with status code 403.
  * Otherwise the $result is returned.
  *
  * @param string       $route       Route pattern. i.e: "admin/*"
  * @param array|string $roles       The role(s) needed
  * @param array|string $permissions The permission(s) needed
  * @param mixed        $result      i.e: Redirect::to('/')
  * @param bool         $requireAll  User must have all roles and permissions
  *
  * @return void
  */
 public function routeNeedsRoleOrPermission($route, $roles, $permissions, $result = null, $requireAll = false)
 {
     $filterName = is_array($roles) ? implode('_', $roles) : $roles;
     $filterName .= '_' . (is_array($permissions) ? implode('_', $permissions) : $permissions);
     $filterName .= '_' . substr(md5($route), 0, 6);
     $closure = function () use($roles, $permissions, $result, $requireAll) {
         $hasRole = $this->hasRole($roles, $requireAll);
         $hasPerms = $this->can($permissions, $requireAll);
         if ($requireAll) {
             $hasRolePerm = $hasRole && $hasPerms;
         } else {
             $hasRolePerm = $hasRole || $hasPerms;
         }
         if (!$hasRolePerm) {
             return empty($result) ? $this->app->abort(403) : $result;
         }
     };
     // Same as Route::filter, registers a new filter
     $this->app->router->filter($filterName, $closure);
     // Same as Route::when, assigns a route pattern to the
     // previously created filter.
     $this->app->router->when($route, $filterName);
 }
Ejemplo n.º 5
0
 /**
  * Throw an HttpException with the given data.
  *
  * @param int $code
  * @param string $message
  * @param array $headers
  * @return void 
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  * @static 
  */
 public static function abort($code, $message = '', $headers = array())
 {
     \Illuminate\Foundation\Application::abort($code, $message, $headers);
 }
Ejemplo n.º 6
0
 /**
  *
  */
 private function checkPageStatus()
 {
     if ($this->page->is_trashed || !$this->page->is_visible || $this->page->is_hidden) {
         $this->app->abort('404');
     }
 }