Skip to content

Commit

Permalink
feat: 增加操作列权限控制
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang committed May 7, 2024
1 parent a008521 commit 41a7b46
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/blazor/client/BootstrapClient.Web.Core/AdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ public Task<bool> AuthorizingNavigation(string userName, string url)
/// <exception cref="NotImplementedException"></exception>
public bool AuthorizingBlock(string userName, string url, string blockName)
{
// Client 暂时未使用
return true;
var ret = User.GetRoles(userName).Any(i => i.Equals("Administrators", StringComparison.OrdinalIgnoreCase));
if (!ret)
{
var menus = Navigations.GetMenus(userName);
var menu = menus.FirstOrDefault(m => m.Url.Contains(url, StringComparison.OrdinalIgnoreCase));
if (menu != null)
{
ret = menus.Any(m => m.ParentId == menu.Id && m.IsResource == DataAccess.Models.EnumResource.Block && m.Url.Equals(blockName, StringComparison.OrdinalIgnoreCase));
}
}
return ret;
}
}

0 comments on commit 41a7b46

Please sign in to comment.