问题描述
我一直在尝试学习本教程 http://donna-oberes.blogspot.co.uk/2013/09/user-login-and-logout-step-by-step-with.html 一步一步.当我尝试使用不正确的用户名登录时密码有效的代码似乎有效...但是当我输入正确的密码时,我收到此错误.
I have been trying to follow this tutorial http://donna-oberes.blogspot.co.uk/2013/09/user-login-and-logout-step-by-step-with.html step by step. When I try to login with a incorrect username & password the code works seems to work... but when I enter the correct one I get this error.
没有找到GET/"的路由(来自/app/path/web/app_dev.php/login")
目前我的文件结构是这样的.
Currently my file structures looks like this.
routing_dev.yml
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
login:
pattern: /login
defaults: { _controller: SimpleProfileBundle:Security:login }
login_check:
pattern: /login_check
test_security:
pattern: /secure_area
defaults: {_controller: SimpleProfileBundle:Security:dumpString }
security.yml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
Simple\ProfileBundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
main:
entity:
class: Simple\ProfileBundle\Entity\User
property: username
firewalls:
secured_area:
pattern: ^/
anonymous: ~
form_login:
login_path: login
check_path: login_check
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/demo/secured/login$
security: false
access_control:
- { path: ^/secure_area, roles: ROLE_ADMIN }
有什么想法吗?谢谢
推荐答案
我认为错误消息描述了这里的问题.您没有为 /
定义路由.当您尝试使用错误的凭据登录时,您会被重定向到登录(有 路由).但是,如果你成功了,你会被重定向到 /
.您还没有为根定义路由.
I think the error message describes the problem here. You do not have a route defined for /
. When you try to log in with the wrong credentials, you get redirected to the login (for which there is a route). But, if you succeed, you get redirected to /
. You do not yet have a route defined for the root.
您必须添加如下路线:
index:
pattern: /
defaults: { _controller: YourBundle:IndexController:index }
这篇关于没有找到“GET/"的路由Symfony 登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!