feat: 添加代码块是否授权方法
This commit is contained in:
parent
05f0d1d344
commit
267d0e68bd
|
@ -1,4 +1,5 @@
|
||||||
using BootstrapAdmin.Caching;
|
using System;
|
||||||
|
using BootstrapAdmin.Caching;
|
||||||
using BootstrapAdmin.DataAccess.Models;
|
using BootstrapAdmin.DataAccess.Models;
|
||||||
using BootstrapAdmin.Web.Core;
|
using BootstrapAdmin.Web.Core;
|
||||||
using PetaPoco;
|
using PetaPoco;
|
||||||
|
@ -66,4 +67,21 @@ class NavigationService : INavigation
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AuthorizationBlock(string userName, string url, string authKey)
|
||||||
|
{
|
||||||
|
var menus = GetAllMenus(userName);
|
||||||
|
|
||||||
|
var activeMeun = menus.FirstOrDefault(s => s.Url.Equals($"~/{url}", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (activeMeun == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<string> authorKeys = from m in menus
|
||||||
|
where m.ParentId == activeMeun.Id && m.IsResource == EnumResource.Block
|
||||||
|
select m.Url;
|
||||||
|
|
||||||
|
return authorKeys.Any(s => s.Equals(authKey, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,13 @@ public interface INavigation
|
||||||
/// <param name="menuIds"></param>
|
/// <param name="menuIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool SaveMenusByRoleId(string? roleId, List<string> menuIds);
|
bool SaveMenusByRoleId(string? roleId, List<string> menuIds);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="authKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool AuthorizationBlock(string userName, string url, string authKey);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue