Base solution for your next web application
Open Closed

How to link and restrict page based on feature #11236


User avatar
0
shedspotter created

What is your product version? 11.0.0

What is your product type (Angular or MVC)? Angular

What is product framework type (.net framework or .net core)? .NET 6

Hi , we have a requirement in which we need to link menu items with feature which we have achived but now we are facing an issue that the page is hide from menu item but user is able to access the page via routing, so please let us know how can we restrict the page access via routhing if feature is not enabled for a tenant

Thanks


7 Answer(s)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @shedspotter

    Maybe this page can help you, https://aspnetboilerplate.com/Pages/Documents/Feature-Management#checking-features

  • User Avatar
    0
    shedspotter created

    Hi, m.aliozkaya this page is not getting help, I need help in angular site not backend site I'll explain you again for example : we have language in left navigation menu , and the date which show in left navigation is coming from AppNavigationService inside this aap service AppMenuItem in which we can link the menu item with feature. so we have linked the language with feature , now if we turn off the feature, language is hide from menu item but the language page we are able to access through URL in front end. so please help us to understand how can we prevent user to access the language page through URL if language featue is not enabled for any tenant

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Could you share your MenuItem definition on Angular side ?

  • User Avatar
    0
    shedspotter created

    Hi @ismcagdas, this how we linked the Languages with feature new AppMenuItem('Languages', 'Pages.Administration.Languages', 'la la-language', '/app/admin/languages', ['/app/admin/languages/{name}/texts'], [], false, null, languageFeatureIsEnabled ? undefined : false),

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Instead of providing languageFeatureIsEnabled ? undefined : false, could you provide a function which checks the related feature value ?

    new AppMenuItem('Languages', 'Pages.Administration.Languages', 'la la-language', '/app/admin/languages', ['/app/admin/languages/{name}/texts'], [], false, null, function(){
        // check if feature is enabled or not...
    }),
    
  • User Avatar
    0
    shedspotter created

    Hi @ismcagdas issue is not related to the app menu item , 'languageFeatureIsEnabled ? undefined : false' working correctly, it will hide the item from nav menu but we can access that page from browser URL using '/app/admin/languages' how can we retrict access from browser URL if feature is not enabled. Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Thanks, got it now. Could you create an issue on https://github.com/aspnetzero/aspnet-zero-core ? We will fix this problem.