Skip to content
Snippets Groups Projects
Commit 444829f3 authored by Andrew Rudenets's avatar Andrew Rudenets
Browse files

Исправление процедуры выхода и бага с проверкой полномочий

parent ea7d0c89
Branches
Tags
No related merge requests found
......@@ -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',
......
......@@ -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)
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment