0

When I was in dev environnement all goes right and my login work fine but when I put my app in a server and change the environement to prod I get this error

Symfony2 : Unable to find the controller for path "/api/login_check". The route is wrongly configured.

I know this question is very pupular in the forms but I ve look at all the response and try to resolve this problem but no one work for me.

this is my security.yml

security:
    encoders:
            Project\MyBundle\Entity\User: sha512

    role_hierarchy:
            ROLE_USER:     ROLE_USER
            ROLE_ADMIN:    ROLE_ADMIN
    providers:
        in_memory:
            memory: ~
        user:
            entity:
                class: MyBundle:User
                property: username

    firewalls:

        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
             pattern:  ^/api/login
             stateless: true
             anonymous: true
             form_login:
                 check_path: /api/login_check
                 provider: user
                 success_handler:         lexik_jwt_authentication.handler.authentication_success
                 failure_handler:          lexik_jwt_authentication.handler.authentication_failure
                 require_previous_session: false

        api:
            pattern:   ^/api
            stateless: true
            provider: user
            lexik_jwt: ~

        main:
                    anonymous: ~


    access_control:
        - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api,       roles: [ROLE_USER, ROLE_ADMIN] }

and this is my routing.yml

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

api_login_check:
    path: /api/login_check

#REST
rest:
  type : rest
  resource : Project\MyBundle\Controller\MyController
  prefix : /api

It's the first time I deploy a symfony project I spent a lot of time with this error hope someone can help me ..thanks in advance

2 Answers 2

1

The login_check is not available with "GET" Request, You have to force it on "POST" request.You can create it like @federico show you

fos_user_security_check:
    path: /login_check
    defaults: { _controller: SiteUserBundle:Security:check }
    requirements:
        _method: POST
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for your response but when I add requirements I get fatal error and when i prefix the method by POST to force the request on POST I get this error : /api/login_check is not callable
What kind of error you have when you add the requirement? Otherwise, you can set GET|POST to the method of the requirement. To check if you really have access to the controller. Let me know
0

As it works when in dev mode but not when in prod mode, it might be that you simply didn’t clear the cache. (Especially as you write it’s your first Symfony deployment.) To do that, execute:

For Sf3: ./bin/console --env=prod cache:clear

For Sf2.4: ./app/console --env=prod cache:clear

1 Comment

I delete the cache folder manually because I don't know how can I access to symfony console in the server. And after that I give 777 permission to the cache folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.