Improve session handler and add Ajax session check
This commit is contained in:
@@ -14,6 +14,16 @@ use Helper;
|
||||
*/
|
||||
class App extends Base
|
||||
{
|
||||
/**
|
||||
* Check if the user is connected
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$this->response->text('OK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard for the current user
|
||||
*
|
||||
|
||||
@@ -140,7 +140,7 @@ abstract class Base
|
||||
public function beforeAction($controller, $action)
|
||||
{
|
||||
// Start the session
|
||||
$this->session->open(BASE_URL_DIRECTORY, SESSION_SAVE_PATH);
|
||||
$this->session->open(BASE_URL_DIRECTORY);
|
||||
|
||||
// HTTP secure headers
|
||||
$this->response->csp(array('style-src' => "'self' 'unsafe-inline'"));
|
||||
@@ -161,6 +161,11 @@ abstract class Base
|
||||
|
||||
// Authentication
|
||||
if (! $this->authentication->isAuthenticated($controller, $action)) {
|
||||
|
||||
if ($this->request->isAjax()) {
|
||||
$this->response->text('Not Authorized', 401);
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=user&action=login&redirect_query='.urlencode($this->request->getQueryString()));
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ class Board extends Base
|
||||
if ($project_id > 0 && $this->request->isAjax()) {
|
||||
|
||||
if (! $this->projectPermission->isUserAllowed($project_id, $this->acl->getUserId())) {
|
||||
$this->response->status(401);
|
||||
$this->response->text('Forbidden', 403);
|
||||
}
|
||||
|
||||
$values = $this->request->getJson();
|
||||
@@ -366,7 +366,7 @@ class Board extends Base
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->response->status(401);
|
||||
$this->response->status(403);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ class Board extends Base
|
||||
$timestamp = $this->request->getIntegerParam('timestamp');
|
||||
|
||||
if ($project_id > 0 && ! $this->projectPermission->isUserAllowed($project_id, $this->acl->getUserId())) {
|
||||
$this->response->text('Not Authorized', 401);
|
||||
$this->response->text('Forbidden', 403);
|
||||
}
|
||||
|
||||
if ($this->project->isModifiedSince($project_id, $timestamp)) {
|
||||
@@ -402,7 +402,7 @@ class Board extends Base
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->response->status(401);
|
||||
$this->response->status(403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user