Skip to content

Commit 8de101e

Browse files
committed
minor #19867 The #[IsCsrfTokenValid] attribute eliminates the need for a request parameter in your method. (rcsofttech85)
This PR was merged into the 7.1 branch. Discussion ---------- The #[IsCsrfTokenValid] attribute eliminates the need for a request parameter in your method. #[IsCsrfTokenValid] attribute in Symfony 7.1 does not require you to include a request parameter in the method itself. The attribute uses the request object internally to access the submitted data for validation. for example ```php #[Route(path: '/admin/post/delete', name: 'admin_post_delete', methods: ['POST'])] #[IsCsrfTokenValid('delete-item')] public function adminPostDelete(): Response { dd('deleted'); } ``` Commits ------- 979891b Removed unnecessary Request parameter
2 parents b80bbc7 + 979891b commit 8de101e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/csrf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ attribute on the controller action::
176176
// ...
177177

178178
#[IsCsrfTokenValid('delete-item', tokenKey: 'token')]
179-
public function delete(Request $request): Response
179+
public function delete(): Response
180180
{
181181
// ... do something, like deleting an object
182182
}

0 commit comments

Comments
 (0)