fix: Client 演示工程无法打开 Home/Dummy 视图错误

This commit is contained in:
Argo Zhang 2020-03-19 14:14:06 +08:00
parent d003d2aaac
commit fb40cfff10
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 23 additions and 0 deletions

View File

@ -37,5 +37,14 @@ namespace Bootstrap.Client.DataAccess
/// <param name="userName"></param>
/// <returns></returns>
public static IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName) => CacheManager.GetOrAdd($"{RetrieveMenusAll}-{userName}", key => DbContextManager.Create<Menu>()?.RetrieveAllMenus(userName), RetrieveMenusAll) ?? new BootstrapMenu[0];
/// <summary>
/// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool
/// </summary>
/// <param name="userName">当前操作用户名</param>
/// <param name="url">资源按钮所属菜单</param>
/// <param name="auths">资源授权码</param>
/// <returns></returns>
public static bool AuthorizateButtons(string userName, string url, string auths) => DbContextManager.Create<Menu>()?.AuthorizateButtons(userName, url, auths) ?? false;
}
}

View File

@ -15,5 +15,18 @@ namespace Bootstrap.Client.DataAccess
/// <param name="userName">当前登录的用户名</param>
/// <returns></returns>
public virtual IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName) => DbHelper.RetrieveAllMenus(userName);
/// <summary>
/// 通过当前用户名与指定菜单路径获取此菜单下所有授权按钮集合 (userName, url, auths) => bool
/// </summary>
/// <param name="userName">当前操作用户名</param>
/// <param name="url">资源按钮所属菜单</param>
/// <param name="auths">资源授权码</param>
/// <returns></returns>
public virtual bool AuthorizateButtons(string userName, string url, string auths)
{
var menus = MenuHelper.RetrieveAllMenus(userName);
return DbHelper.AuthorizateButtons(menus, url, auths);
}
}
}

View File

@ -49,6 +49,7 @@ namespace Bootstrap.Client
services.AddOnlineUsers();
services.AddBootstrapAdminAuthentication(Configuration);
services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build());
services.AddButtonAuthorization(MenuHelper.AuthorizateButtons);
services.AddControllersWithViews(options =>
{