/** * A Before Filter which permit the access to Administrators. */ public function adminUsersFilter(Route $route, Request $request) { // Check the User Authorization - while using the Extended Auth Driver. if (!Auth::user()->hasRole('administrator')) { $status = __d('users', 'You are not authorized to access this resource.'); return Redirect::to('admin/dashboard')->withStatus($status, 'warning'); } }
/** * Handle an exception for the application. * * @param \Exception $exception * @return \Symfony\Component\HttpFoundation\Response */ public function handleException($exception) { if ($exception instanceof RedirectToException) { // Manage the Redirect comming from the Helpers\Url. $url = $exception->getUrl(); if (is_null($url)) { return Redirect::back($exception->getStatusCode()); } else { return Redirect::to($url, $exception->getStatusCode()); } } else { if (!$exception instanceof Exception) { $exception = new FatalThrowableError($exception); } } $response = $this->callCustomHandlers($exception); if (!is_null($response)) { return $this->prepareResponse($response); } return $this->displayException($exception); }