WilliamXu96 / ABP-MicroService

基于abp微服务架构的低代码平台
1.09k stars 329 forks source link

web层的菜单不回显示 #17

Closed LFeYls closed 3 years ago

LFeYls commented 3 years ago

大佬,请教个问题,我用官方的微服务demo进行,自己添加了一个SmsSenderManagement模块 在Web层中的SmsSenderManagementMenuContributor中添加菜单的时候,使用MenuConfigurationContext.IsGrantedAsync()验证权限添加菜单,发现自己添加的模块中的权限一直验证不通过 private async Task ConfigureMainMenu(MenuConfigurationContext context) { //Add main menu items.

        var l = context.GetLocalizer<SmsSenderManagementResource>();

        var rootMenuItem = new ApplicationMenuItem("SmsSenderManagement", l["Menu:SmsSenderManagement"]);

//调试发现,此处返回值为false,但是源码中的Product模块中的ProductManagement.Product”验证是返回true的 if (await context.IsGrantedAsync(SmsSenderPermissionNames.SmsSenderSetting)) { if (await context.IsGrantedAsync(SmsSenderPermissionNames.Global)) { rootMenuItem.AddItem(new ApplicationMenuItem("Global", l["Menu:Global"], "/SmsSenderManagement")); }

            if (await context.IsGrantedAsync(SmsSenderPermissionNames.Common))
            {
                rootMenuItem.AddItem(new ApplicationMenuItem("Common", l["Menu:Common"], "/SmsSenderManagement"));
            }
        }
        context.Menu.AddItem(rootMenuItem);
    }

在AuthServer.Host的种子数据中添加也模仿Product模块添加了权限

        await CreateClientAsync(
            "backend-admin-app-client",
            commonScopes.Union(new[]
            {
                "BackendAdminAppGateway", "PermissionManagementService", "IdentityService", "ProductService",
                "SmsSenderService", "TenantManagementService"
            }),
            new[] {"hybrid"},
            commonSecret,
            permissions: new[] {
                   IdentityPermissions.Users.Default, "ProductManagement.Product", 
                   "SmsSender.SmsSenderSetting","SmsSenderManagement.Settings"},
            redirectUri: "https://localhost:44354/signin-oidc",
            postLogoutRedirectUri: "https://localhost:44354/signout-callback-oidc"
        );