Saturday, December 28, 2013

Security Component Help

I want to make action requests more secure by implementing the Restricting HTTP methods { requirePost(),requireGet(), requirePut(), requireDelete()} but running into a bit of an issue.

For an add request for example via ajax I have to fetch the form (get) and load it into the colorbox, and save the input gets sent as post. So the add method invokes 2 separate HTTP methods.

Other than break the public function add() into 2 separate functions such as

public function load() // fetch the form via get

and then
public function save()// post to save the data

Is there another way to accomplish this without having to break up the function?

I currently have:

public function save(){

                //load the form

                if($this->request->is('ajax') && $this->request->is('get')) {

                                …

                }

 

                //save the form

                if (!empty($this->request->data) && $this->request->is('post')) {

                                ….

                }

}

 

Any ideas anyone the best way to handle this?

Thanks,

 

Dave

 

No comments: