简体   繁体   中英

how to authenticate ROLE_USER and ROLE_ADMIN separately in fos userbundle

I have made two different login section in my website, one for admin section and another for frontend users.

When I logged into to frontend it logged in. The problem is that when i try to login the admin section it throws access denied error.

Is it possible make two different login sessions so that both login session are independent of eachother

you don't show security.yml, so no way to know for sure:

try deleting this row:

- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY } 

but most likely you have something like this in your security.yml

    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 }
    - { path: ^/, role: ROLE_USER }

and your login page is on url /admin/login/

so it requires ROLE_ADMIN to access login page, before you can login as admin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM