找不到路径的控制器

时间:2019-12-26 04:19:26

标签: php jwt symfony4

我正在尝试将jwt实施到symfony项目。我一直在关注许多教程。但是还没有真正使我工作。 我收到Unable to find the controller for path "/login". The route is wrongly configured.错误。

下面是我设置的配置。我需要在控制器内创建登录功能吗?

security.yaml

security:
    encoders:
        App\Entity\Users:
            algorithm: bcrypt
    providers:
        app_user_provider:
            entity:
                class: App\Entity\Users
                property: email
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern: ^/login
            stateless: true
            anonymous: true
            json_login:
                check_path: /login
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
        register:
            pattern:  ^/register
            stateless: true
            anonymous: true
        api:
            pattern: ^/api
            stateless: true
            anonymous: false
            provider: app_user_provider
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
        main:
            anonymous: true
    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

routes.yaml

# Register api
register:
    path: /register
    controller: App\Controller\AuthController::register
    methods: ['POST']

api:
    path: /api
    controller: App\Controller\AuthController::api
    methods: ['POST']

login:
    path: /login
    methods: ['POST']

0 个答案:

没有答案