diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php index 830f0fd18..db1255b95 100644 --- a/app/Controller/AppController.php +++ b/app/Controller/AppController.php @@ -122,6 +122,12 @@ public function beforeFilter() { // XXX CO-351 Placeholder $this->Session->write('Config.language', 'eng'); + // CSRF token should expire along with the Session. This is the default in CAKEPHP 3.7.x+ + // https://book.cakephp.org/3/en/controllers/middleware.html#csrf-middleware + // https://github.com/cakephp/cakephp/issues/13532 + // - expiry, How long the CSRF token should last. Defaults to browser session. + $this->Security->csrfUseOnce = false; + Configure::write('Config.language', $this->Session->read('Config.language')); // Tell the Auth module to call the controller's isAuthorized() function. diff --git a/app/Controller/CoPeopleController.php b/app/Controller/CoPeopleController.php index 92f3e7cf7..d02db0029 100644 --- a/app/Controller/CoPeopleController.php +++ b/app/Controller/CoPeopleController.php @@ -252,6 +252,7 @@ public function canvas($id) { // This is pretty similar to the standard view or edit methods. if(!$this->request->is('restful') && $this->request->is('get')) { + $this->set('vv_title_status_bg', true); $this->edit($id); } } diff --git a/app/Controller/StandardController.php b/app/Controller/StandardController.php index b59c2e558..a96808014 100644 --- a/app/Controller/StandardController.php +++ b/app/Controller/StandardController.php @@ -538,7 +538,15 @@ function edit($id) { return; } - + + // Complete the request with the `status` field if it is of type PUT + // Usefull for asychronous single-field Requests + if($req === 'CoPerson' + && empty($this->request->data[$req]["status"]) + && !empty($curdata[$req]["status"])) { + $this->request->data[$req]["status"] = $curdata[$req]["status"]; + } + $data = $this->request->data; if(!isset($this->request->data[$req]['id'])) { @@ -633,6 +641,14 @@ function edit($id) { if($this->request->is('restful')) { $this->Api->restResultHeader(200, "OK"); + } elseif ($this->request->is('ajax')) { + // Return the new data + $this->layout = null; + $this->autoRender = false; + $this->response->type('json'); + $this->response->statusCode(201); + $this->response->body(json_encode(array(0 => $data))); + return $this->response; } else { // Redirect to index view diff --git a/app/View/CoPeople/fields.inc b/app/View/CoPeople/fields.inc index bb1dccef8..96533f757 100644 --- a/app/View/CoPeople/fields.inc +++ b/app/View/CoPeople/fields.inc @@ -343,6 +343,10 @@