自定义表单登录验证程序响应

编辑本页

安全说明了这个验证器的用法。

http://www.example.com/admin/post/18/edit,然后在他们成功登录后,他们将被发送回http://www.example.com/admin/post/18/edit

这是通过将请求的URL存储在会话中来实现的。如果会话中没有URL(可能用户直接跳转到登录页面),那么用户将被重定向到/(即网页)。您可以通过几种方式改变这种行为。

failure_path选项,通过相对/绝对URL或Symfony路由名定义一个新目标:ob娱乐下载

  • YAML
  • XML
  • PHP
1 2 3 4 5 6 7 8 9 10
#配置/包/ security.yaml安全:#……防火墙:主要:#……form_login:#……failure_path:login_failure_route_name

此选项也可以通过_failure_path请求参数:

1
http://example.com/some/path?_failure_path=/forgot-password
1 2 3 4 5 6 7
{/安全/ login.html #模板。树枝#}<形式行动{{path('login')}}方法“职位”>{#……#}<输入类型“隐藏”的名字“_failure_path”价值{{path('忘记密码')}}/><输入类型“提交”的名字“登录”/>形式>

target_path_parameter而且failure_path_parameter定义登录表单的防火墙的选项。

  • YAML
  • XML
  • PHP
1 2 3 4 5 6 7 8 9 10
#配置/包/ security.yaml安全:#……防火墙:主要:#……form_login:target_path_parameter:go_tofailure_path_parameter:back_to

使用上面的配置,查询字符串参数和隐藏表单字段现在是完全定制的:

1
http://example.com/some/path?go_to=/dashboard&back_to=/forgot-password
1 2 3 4 5 6 7 8
{/安全/ login.html #模板。树枝#}<形式行动{{path('login')}}方法“职位”>{#……#}<输入类型“隐藏”的名字“go_to”价值{{path('dashboard')}}/><输入类型“隐藏”的名字“back_to”价值{{path('忘记密码')}}/><输入类型“提交”的名字“登录”/>形式>

ob娱乐下载Symfony 6.0支持通过SensioLabs