Lexikjwtauthenticationbundle: Symfony 4 + json_login exemple

Created on 12 Jan 2018  路  5Comments  路  Source: lexik/LexikJWTAuthenticationBundle

Hi there,

Thx a lot for your bundle.

I'm trying to transform form_login to a json_login for an api. With form_login everything works, but when i'm trying to have a json_login got this error:

[warning] Unable to look for the controller as the "_controller" parameter is missing.

security:
    firewalls:
        login:
            pattern:  ^/user/login
            stateless: true
            anonymous: true
            provider: user_provider
            json_login:
                check_path:               user.login
                username_path:            email
                password_path:            password
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false

It's like symfony system authentication does not work with json_form.

Any idea ?

Thx for advance;

Most helpful comment

Here is a working example using json_login under symfony 4 (flex): https://github.com/chalasr/lexik-jwt-authentication-sandbox/tree/flex.
Feedback welcomed, I'll soon take time to update the bundle documentation accordingly.

All 5 comments

Hello @christophe-mailfert, please try to follow examples in this article http://symfony.com/doc/current/security/json_login_setup.html

Here is a working example using json_login under symfony 4 (flex): https://github.com/chalasr/lexik-jwt-authentication-sandbox/tree/flex.
Feedback welcomed, I'll soon take time to update the bundle documentation accordingly.

Hello @chalasr! Could you please give an answer, is there a way to return a token after the registration or it's bad practice? Thank you.

Thx all for your return.

Seems work when i'm in production mode, but fail and i launch my unit test. I will try to provide an example asap :)

@kavw fine for me.

I'm closing here due to the lack of feedback, feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reducio picture reducio  路  4Comments

Cypaubr picture Cypaubr  路  5Comments

mflasquin picture mflasquin  路  5Comments

Zempheroth picture Zempheroth  路  4Comments

garak picture garak  路  5Comments