Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:51:21+00:00 2026-06-10T21:51:21+00:00

I have a admin panel and I have defined a role for it ROLE_ADMIN

  • 0

I have a admin panel and I have defined a role for it ROLE_ADMIN. In my security.yml file I am using a pattern ^/admin/* so every thing under /admin requires ROLE_ADMIN. Now in frontend of my app I need to check user role and if role is ROLE_ADMIN render one file and otherwise render another file. This url does not fall under the pattern defined in security.yml.

So how do I check whether the user is admin or a normal user on the homepage which does not fall under the pattern defined in security.yml ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:51:23+00:00Added an answer on June 10, 2026 at 9:51 pm

    Enable the firewall on the whole app using the ^/ pattern, permit anonymous access and use access_control to restrict access:

    security:
        firewalls:
            secured_area:
                pattern: ^/
                anonymous: ~
    
        access_control:
            - { path: ^/admin, roles: ROLE_ADMIN }
    

    As @itsmequinn suggested, use the isGranted() method of the security context:

    if ($this->get('security.context')->isGranted('ROLE_BRAND')) {
        // the user has the ROLE_BRAND role, so act accordingly
    }
    

    In Symfony 2.6, security.context has been split into two separate services. Hence you need to use the security.authorization_checker service to solve the problem:

    if ($this->get('security.authorization_checker')->isGranted('ROLE_BRAND')) {
        // the user has the ROLE_BRAND role, so act accordingly
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project, have setup an admin panel under a folder inside controllers folder
I am using my admin panel login script where i have created a global.php
I tried to make admin panel and I am using sessions , but have
I have created an admin panel for a client in PHP, which requires a
i am using codeigniter 2.1.0 and mysql database. in my admin panel i have
I have a FieldSet : Ext.define('admin.view.BuzzEditForm', { extend: 'Ext.form.Panel', requires: ['Ext.form.FieldSet','Ext.Img'], id: 'editorPanel', xtype:
I have a fieldset like this : Ext.define('admin.view.BuzzEditForm', { extend: 'Ext.form.Panel', requires: ['Ext.form.FieldSet','Ext.Img'], id:
I have created web service in c#.In that admin panel when admin edit file
I have a question regarding the Magento options found under: Admin Panel -> System
I have a log function on my admin panel that checks user input for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.