This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Cannot login (FOSUserBundle, Security Component)

Discuss Symfony 2 bundles here

Cannot login (FOSUserBundle, Security Component)

by alch3m1st » Wed May 23, 2012 12:30 am

I have followed the manual and created MyBundle which extends FOSUserBundle,

Everything works ok so far, I can

1)register a user 2)send him email 3)confirmed his account (after confirmation I am logged in) 4)logout

but afterwords I cannot login.
A query is fired (as seen in the logs below) but the login form error is always "Bad credentials...".

The user is enabled in the database.
My password field inside the database , for the newly created user, uses both sha512 encryption + salt.



I am using , in security.yml


Code: Select all
security:
    encoders:
        'FOS\UserBundle\Model\UserInterface': sha512


    providers:
        fos_userbundle:
            id: fos_user.user_manager


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

        UsersFirewall:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
                check_path: fos_user_security_check
                login_path: fos_user_security_login
            logout:
                path: fos_user_security_logout
                target: /
            anonymous: true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN



config.yml

Code: Select all
fos_user:
    db_driver: orm
    firewall_name: doctors
    user_class: Acme\MyBundle\Entity\MyUser
    service:
        mailer: fos_user.mailer.twig_swift


MyUser simply extends FOS\UserBundle\Entity\User



Should I change my extended user in any way to use 512 encoder and salt when comparing the db password and the one the user provided?

Or can anyone guide me on how to debug this?



Code: Select all
[2012-05-22 22:16:19] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2012-05-22 22:16:19] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2012-05-22 22:16:19] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2012-05-22 22:16:19] request.INFO: Matched route "fos_user_security_check" (parameters: "_controller": "FOS\UserBundle\Controller\SecurityController::checkAction", "_route": "fos_user_security_check") [] []
[2012-05-22 22:16:19] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2012-05-22 22:16:19] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2012-05-22 22:16:19] doctrine.DEBUG: SET NAMES UTF8 ([]) [] []
[2012-05-22 22:16:19] doctrine.DEBUG: SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17 FROM doctors t0 WHERE t0.username_canonical = ? LIMIT 1 (["papadopoulos"]) [] []
[2012-05-22 22:16:19] security.INFO: Authentication request failed: Bad credentials [] []
[2012-05-22 22:16:19] security.DEBUG: Redirecting to fos_user_security_login [] []
[2012-05-22 22:16:19] event.DEBUG: Listener "Symfony\Component\Security\Http\Firewall::onKernelRequest" stopped propagation of the event "kernel.request". [] []


I am really stuck on this...
alch3m1st
Junior Member
 
Posts: 1
Joined: Wed May 23, 2012 12:23 am

Re: Cannot login (FOSUserBundle, Security Component)

by Ail5urfer » Thu May 28, 2015 8:55 am

Hello,

Have you found a solution for this problem :?:

I have something similar, my project runs fine on my dev machine, but when I run it on production server, I can't connect :-(
=> "Bad credentials." message at each attempts...
My symfony 1.4 site : Kitchen Convert Tools : adjust recipes quantities
My Symfony2 lab site : MusiqueEntrePotes : easily share streaming music links
SGNFM
Ail5urfer
Junior Member
 
Posts: 4
Joined: Sun Sep 16, 2012 4:27 pm