I've just found the solution to my problem. The cause was LswMemcacheBundle
,
I have installed memcached
php extension, but i haven't run memcache
on my system. I've run it and afterwards all login/logout functionalities have started working correctly.
Symfony FOSUserBundle does not authenticate users and does not advise bad credentials
-
26-06-2023 - |
Question
I have installed FOSUserBundle
, I see that's active and my login page is ok too. The problem comes out when I try to login as an user. If I insert wrong credentials, nothing happens, I'm redirected to the login page without signalling "bad credentials" as usual. If I insert right user information, I'm redirected to the homepage and I'm not logged in, in the Symfony
toolbar I'm authenticated as anonymous and I have only an AnonymousToken.
This is my security.yml:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: fos_user_security_login
check_path: fos_user_security_check
csrf_provider: form.csrf_provider
logout: true
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 }
This is part of my config.yml:
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: ***\***Bundle\Entity\User
In Symfony log, I can read:
security.INFO: User "sampleuser" has been authenticated successfully [] []
but this is apparently not happening.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow