Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

check permission at client side? #254


User avatar
0
reji79 created

I am wondering any facility exists in the framework to check user permission at client side. I have anangular application and want to redirect to an error page if user tries to access a page that not allowedbecause of the permission. The menu is currently built using permission, but user can directly type path and access the page. But they wont be allowed to save because I am implementing AbpAuthorize attribute at server side. But I do not want show them the page at first place if they have no access.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Define angular routes conditional. Sample:

    if (abp.auth.hasPermission('Pages.Administration.Roles')) {
                $stateProvider.state('roles', {
                    url: '/roles',
                    templateUrl: '~/App/common/views/roles/index.cshtml',
                    menu: 'Administration.Roles'
                });
            }
    

    So, you can use abp.auth.hasPermission to check auth on client side. I'll add it to docs: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/555">https://github.com/aspnetboilerplate/as ... issues/555</a>

    Thanks.