Skip to content

Instantly share code, notes, and snippets.

@bernard-ng
Created December 23, 2020 13:57
Show Gist options
  • Save bernard-ng/0b6c945ba38bd54acbe694c93f5c1937 to your computer and use it in GitHub Desktop.
Save bernard-ng/0b6c945ba38bd54acbe694c93f5c1937 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpFoundation\Request;
// ...
public function delete(Request $request)
{
$submittedToken = $request->request->get('token');
// "delete-item" est la même valeur que celle utilisée dans le modèle pour générer le jeton
if ($this->isCsrfTokenValid('delete-item', $submittedToken)) {
// ... faire quelque chose, comme supprimer un objet
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment