Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions user_guide_src/source/libraries/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,22 @@ Do one of the following:

E.g.::

if (strtolower($this->request->getMethod()) !== 'post') {
if (! $this->request->is('post')) {
return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
}

.. note:: The :ref:`$this->request->is() <incomingrequest-is>` method can be used since v4.3.0.
In previous versions, you need to use
``if (strtolower($this->request->getMethod()) !== 'post')``.

When Auto-Routing is Enabled
----------------------------

1. Check the request method in the controller method before processing.

E.g.::

if (strtolower($this->request->getMethod()) !== 'post') {
if (! $this->request->is('post')) {
return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
}

Expand Down
4 changes: 4 additions & 0 deletions user_guide_src/source/libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ this code and save it to your **app/Controllers/** folder:

.. literalinclude:: validation/001.php

.. note:: The :ref:`$this->request->is() <incomingrequest-is>` method can be used since v4.3.0.
In previous versions, you need to use
``if (strtolower($this->request->getMethod()) !== 'post')``.

The Routes
==========

Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/libraries/validation/001.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Form extends BaseController

public function index()
{
if (strtolower($this->request->getMethod()) !== 'post') {
if (! $this->request->is('post')) {
return view('signup');
}

Expand Down