8000 Add block prefix to csrf token field by alexander-schranz · Pull Request #29862 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add block prefix to csrf token field #29862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public function finishView(FormView $view, FormInterface $form, array $options)
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: \get_class($form->getConfig()->getType()->getInnerType()));
$data = (string) $options['csrf_token_manager']->getToken($tokenId);

$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, array(
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [
'block_prefix' => 'csrf_token',
'mapped' => false,
));
]);

$view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
}
Expand All @@ -103,20 +104,20 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'csrf_protection' => $this->defaultEnabled,
'csrf_field_name' => $this->defaultFieldName,
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
'csrf_token_manager' => $this->defaultTokenManager,
'csrf_token_id' => null,
));
]);
}

/**
* {@inheritdoc}
*/
public static function getExtendedTypes(): iterable
{
return array(FormType::class);
return [FormType::class];
}
}
0