diff --git a/application/bootstrap.php b/application/bootstrap.php index d07975eba7f59cd83a44d95ff4c6415cfa0aeb47..b3e6461d2eb3776ce842f1c7ab88e39cd94993bc 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -158,7 +158,7 @@ Route::set('remind', 'remind') 'action' => 'remind', )); -Route::set('sign/out', 'logout') +Route::set('sign:out', 'sign/out') ->defaults(array( 'controller' => 'authentication', 'action' => 'logout', diff --git a/application/classes/Controller/Handler.php b/application/classes/Controller/Handler.php index c837691f3533bad80b96fdba187e7fd1059174d1..e44fb6b4e52ca5fc81a1d3a53ea7017d54be4701 100644 --- a/application/classes/Controller/Handler.php +++ b/application/classes/Controller/Handler.php @@ -17,19 +17,13 @@ class Controller_Handler extends Controller { if(!$this->request->is_ajax()) { // Перенаправляем на ошибку доступа - throw HTTP_Exception::factory (403); + throw HTTP_Exception::factory (403, 'only ajax'); } // Обработка POST-данных $this->post = Validation::factory(Arr::map('trim', $_POST)); - // Если запрос не прошел на проверку доступа - if(!$this->checkAccessLevel()) - { - // Перенаправляем на ошибку доступа - throw HTTP_Exception::factory (403); - } - + // Если авторизован, получаем данные аккаунта if(Auth::isLoggedIn()) { $model = new Model_Account; @@ -41,6 +35,15 @@ class Controller_Handler extends Controller { unset($this->user['ID']); unset($this->user['Type']); } + + // Если запрос не прошел на проверку доступа + if(!$this->checkAccessLevel()) + { + // Перенаправляем на ошибку доступа + throw HTTP_Exception::factory (403, $this->access); + } + + } protected function setAccessLevel($level) @@ -57,17 +60,17 @@ class Controller_Handler extends Controller { if ($this->access == self::ACCESS_ADMIN) { // TODO: Проверка токена и юзер-агента - return Auth::isLoggedIn () AND $this->user['Type'] == 'admin'; + return Auth::isLoggedIn () AND $this->user['AccountType'] == 'admin'; } elseif ($this->access == self::ACCESS_TEACHER) { // TODO: Проверка токена и юзер-агента - return Auth::isLoggedIn () AND $this->user['Type'] == 'teacher'; + return Auth::isLoggedIn () AND $this->user['AccountType'] == 'teacher'; } elseif ($this->access == self::ACCESS_STUDENT) { // TODO: Проверка токена и юзер-агента - return Auth::isLoggedIn () AND $this->user['Type'] == 'student'; + return Auth::isLoggedIn () AND $this->user['AccountType'] == 'student'; } elseif ($this->access == self::ACCESS_USER) {