Return custom error message when user not enabled

80 Views Asked by At

I have been creating a web application using Symfony(FosUsersBundle) & Angular, when the user types false login informations, even when the user not enabled I always the the same response:

{code: 401, message: "Bad credentials"}

I want to retun the message "not enabled" when the user not enabled.

security.yml

      firewalls:
        api:
         pattern: ^/api
         stateless: true
         lexik_jwt:
            authorization_header:
                enabled: true
                prefix: Bearer
            query_parameter:
                enabled: true
                name: bearer
            throw_exceptions: false
            create_entry_point: true
         login:
            pattern: ^/login
            provider: fos_userbundle
            stateless: true
            form_login:
                check_path: /login_check
                username_parameter: username
                password_parameter: password
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false 

Thank you in advance.

0

There are 0 best solutions below