feat: 添加事件总线
This commit is contained in:
@@ -9,11 +9,17 @@ namespace Yi.Framework.Auth.JwtBearer.Authorization
|
||||
{
|
||||
public class DefaultPermissionHandler : IPermissionHandler
|
||||
{
|
||||
public bool IsPass(string permission, ICurrentUser currentUser)
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
public DefaultPermissionHandler(ICurrentUser currentUser)
|
||||
{
|
||||
if (currentUser.Permission is not null)
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
public bool IsPass(string permission)
|
||||
{
|
||||
if (_currentUser.Permission is not null)
|
||||
{
|
||||
return currentUser.Permission.Contains(permission);
|
||||
return _currentUser.Permission.Contains(permission);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace Yi.Framework.Auth.JwtBearer.Authorization
|
||||
{
|
||||
public interface IPermissionHandler
|
||||
{
|
||||
bool IsPass(string permission,ICurrentUser currentUser);
|
||||
bool IsPass(string permission );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,7 +12,9 @@ using Yi.Framework.Core.Model;
|
||||
|
||||
namespace Yi.Framework.Auth.JwtBearer.Authorization
|
||||
{
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
|
||||
public class PermissionAttribute : ActionFilterAttribute
|
||||
{
|
||||
private string Permission { get; set; }
|
||||
@@ -31,11 +34,7 @@ namespace Yi.Framework.Auth.JwtBearer.Authorization
|
||||
|
||||
var permissionHandler = ServiceLocatorModel.Instance.GetRequiredService<IPermissionHandler>();
|
||||
|
||||
var currentUser = ServiceLocatorModel.Instance.GetRequiredService<ICurrentUser>();
|
||||
|
||||
|
||||
|
||||
var result = permissionHandler.IsPass(Permission, currentUser);
|
||||
var result = permissionHandler.IsPass(Permission);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,15 @@ namespace Yi.Framework.Core.Helper
|
||||
public static class AssemblyHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 此处统一获取程序集,排除微软内部相关
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Assembly[] GetAllLoadAssembly()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies();
|
||||
}
|
||||
|
||||
public static List<Assembly> GetReferanceAssemblies(this AppDomain domain)
|
||||
{
|
||||
var list = new List<Assembly>();
|
||||
|
||||
Reference in New Issue
Block a user