Symfony2:找不到路径"/login_check"的控制器



我一起使用FOSUserBundle和FOSFacebookBundle。我按照官方文档设置它们:

FOSUserBundle 和FOSFacebookBundle

当我使用Facebook按钮登录时,我看到:

Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?<br />
404 Not Found - NotFoundHttpException</p>

app/config/aonfig.cfg

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
framework:
    #esi:             ~
    translator:      { fallback: "%locale%" }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true
# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }
services:
    my.facebook.user:
        class: ISSBlogBundleSecurityUserProviderFacebookProvider
        arguments:
            facebook: "@fos_facebook.api"
            userManager: "@fos_user.user_manager"
            validator: "@validator"
# FOSUserBundle Configuration
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: ISSBlogBundleEntityUser
# FOSFacebookBundle Configuration
fos_facebook:
    alias:  facebook
    app_id: *myId*
    secret: *mySecret*
    cookie: true
    permissions: [email, user_birthday, user_location]
/

app/config/security.yml

security:
    encoders:
        FOSUserBundleModelUserInterface: sha512
    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
    providers:
        chain_provider:
            chain:
                providers: [fos_userbundle, my_fos_facebook_provider]
        fos_userbundle:
            id: fos_user.user_provider.username
        my_fos_facebook_provider:
            id: my.facebook.user
    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:`enter code here`
            pattern: ^/
            switch_user: true
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout: true
            anonymous: true
        public:
            pattern:   ^/.*
            fos_facebook:
                app_url: "http://apps.facebook.com/669439826427579/"
                server_url: "http://issart-company.loc/"
                login_path: /login
                check_path: /login_check
                default_target_path: /
                provider: my_fos_facebook_provider
            anonymous: true
    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, roles: ROLE_ADMIN }
        - { path: ^/secured/.*, role: [IS_AUTHENTICATED_FULLY] } # This is the route secured with fos_facebook
        - { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: ^/facebook/, role: [ROLE_FACEBOOK] }

应用/配置/路由

iss_blog:
    resource: "@ISSBlogBundle/Resources/config/routing.yml"
    prefix:   /
_security_check:
    pattern:  /login_check
_security_logout:
    pattern:  /logout
fos_facebook_channel:
    resource: "@FOSFacebookBundle/Resources/config/routing.xml"
fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile
fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register
fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting
fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /profile
_facebook_secured:
    pattern: /secured/
    defaults: { _controller: ISSBlogBundle:Post:index }

在您的应用程序/配置/路由中,您有未分配控制器的/login_check。您必须像这样配置控制器:

_security_check:
    pattern: /login_check
    defaults: { _controller: ACMEBundle:Controller:action }

您可以在 http://symfony.com/doc/current/book/routing.html

现在,路由系统首先找到在"@FOSUserBundle/资源/配置/路由/安全.xml"中配置的路由系统。如果您希望 FOSUserBundle 处理登录过程,则必须删除_security_check和_security_logout路由。

相关内容

  • 没有找到相关文章

最新更新